From 13dba7c43a6c4b70e06e7818b79028a68781aea4 Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 18 Aug 2025 18:26:02 +0900 Subject: [PATCH] =?UTF-8?q?[20250818]=20BOJ=20/=20P5=20/=20AND,=20OR,=20XO?= =?UTF-8?q?R=202=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- khj20006/202508/18 BOJ P5 AND, OR, XOR 2.md | 146 ++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 khj20006/202508/18 BOJ P5 AND, OR, XOR 2.md diff --git a/khj20006/202508/18 BOJ P5 AND, OR, XOR 2.md b/khj20006/202508/18 BOJ P5 AND, OR, XOR 2.md new file mode 100644 index 00000000..0c0e23b0 --- /dev/null +++ b/khj20006/202508/18 BOJ P5 AND, OR, XOR 2.md @@ -0,0 +1,146 @@ +```java +import java.awt.image.AreaAveragingScaleFilter; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static final long MOD = 998244353; + + static int N; + static int[] a; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + static void init() throws Exception { + + N = io.nextInt(); + a = new int[N+1]; + for(int i=1;i<=N;i++) a[i] = io.nextInt(); + + } + + static void solve() throws Exception { + + io.write(and() + " " + or() + " " + xor()); + + } + + static long and() { + long res = 0; + for(int k=0;k<30;k++) { + for(int i=1;i<=N;) if((a[i] & (1< 0) even++; + } + else odd++; + } + for(int i=1;i<=N;i++) { + if(c[i-1]%2 == 0) res += odd*(1< 0) even--; + } + else odd--; + } + } + return res; + } + +} +```