From d24f4334664cd9596f210b1372e2cddcce31a35a Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 9 Apr 2025 09:58:31 +0900 Subject: [PATCH] =?UTF-8?q?[20250409]=20BOJ=20/=20P4=20/=20=EC=95=84=20?= =?UTF-8?q?=EB=98=90=20XOR=EC=9D=B4=EC=95=BC=3F=20/=20=EA=B6=8C=ED=98=81?= =?UTF-8?q?=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\230\220 XOR\354\235\264\354\225\274?.md" | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 "khj20006/202504/09 BOJ P4 \354\225\204 \353\230\220 XOR\354\235\264\354\225\274?.md" diff --git "a/khj20006/202504/09 BOJ P4 \354\225\204 \353\230\220 XOR\354\235\264\354\225\274?.md" "b/khj20006/202504/09 BOJ P4 \354\225\204 \353\230\220 XOR\354\235\264\354\225\274?.md" new file mode 100644 index 00000000..7f257a07 --- /dev/null +++ "b/khj20006/202504/09 BOJ P4 \354\225\204 \353\230\220 XOR\354\235\264\354\225\274?.md" @@ -0,0 +1,97 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static long N, A, B; + static int K; + static long[][] C; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextLong(); + K = nextInt(); + A = nextLong(); + B = nextLong(); + C = new long[62][62]; + C[0][0] = 1; + for(int i=1;i<=61;i++) { + C[i][0] = 1; + for(int j=1;j= 0) { + for(int zeroSelect = 0;zeroSelect<=zero;zeroSelect++) { + int oneSelect = temp - zeroSelect; + if(oneSelect > one) continue; + if(oneSelect < 0) break; + res += C[zero][zeroSelect] * C[one][oneSelect]; + } + } + + if(cur == 0) zero++; + else one++; + d<<=1; + } + if(x >= d) res += f(n^d, k, x-d) + (bits(n^d) == k ? 1 : 0); + return res; + + } + + static int bits(long x) { + int res = 0; + for(int i=0;i<=60;i++) res += (x & (1L<