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; + } + +} +```