結果
問題 | No.2237 Xor Sum Hoge |
ユーザー | chro_96 |
提出日時 | 2023-03-04 00:54:06 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 2,453 ms / 10,000 ms |
コード長 | 4,966 bytes |
コンパイル時間 | 381 ms |
コンパイル使用メモリ | 34,048 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 00:50:29 |
合計ジャッジ時間 | 49,579 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,400 ms
6,812 KB |
testcase_01 | AC | 25 ms
6,816 KB |
testcase_02 | AC | 8 ms
6,944 KB |
testcase_03 | AC | 25 ms
6,940 KB |
testcase_04 | AC | 25 ms
6,940 KB |
testcase_05 | AC | 26 ms
6,944 KB |
testcase_06 | AC | 26 ms
6,944 KB |
testcase_07 | AC | 26 ms
6,940 KB |
testcase_08 | AC | 26 ms
6,940 KB |
testcase_09 | AC | 26 ms
6,940 KB |
testcase_10 | AC | 27 ms
6,944 KB |
testcase_11 | AC | 514 ms
6,944 KB |
testcase_12 | AC | 2,281 ms
6,944 KB |
testcase_13 | AC | 2,346 ms
6,944 KB |
testcase_14 | AC | 2,290 ms
6,944 KB |
testcase_15 | AC | 514 ms
6,940 KB |
testcase_16 | AC | 2,345 ms
6,944 KB |
testcase_17 | AC | 2,337 ms
6,940 KB |
testcase_18 | AC | 2,352 ms
6,940 KB |
testcase_19 | AC | 2,349 ms
6,944 KB |
testcase_20 | AC | 2,314 ms
6,940 KB |
testcase_21 | AC | 2,318 ms
6,944 KB |
testcase_22 | AC | 2,453 ms
6,944 KB |
testcase_23 | AC | 2,372 ms
6,940 KB |
testcase_24 | AC | 2,328 ms
6,940 KB |
testcase_25 | AC | 2,353 ms
6,944 KB |
testcase_26 | AC | 2,328 ms
6,940 KB |
testcase_27 | AC | 2,362 ms
6,940 KB |
testcase_28 | AC | 2,317 ms
6,944 KB |
testcase_29 | AC | 2,359 ms
6,940 KB |
testcase_30 | AC | 2,336 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 26 ms
6,944 KB |
testcase_34 | AC | 2 ms
6,944 KB |
ソースコード
#include <stdio.h> long long mod_num = 998244353LL; long long root = 3LL; int length = 998244352; long long inverse_root = 0LL; long long inverse_l = 0LL; int log_l = 0; long long pow_root[16] = {}; long long pow_root_inv[16] = {}; long long power_mod (long long a, long long b, long long p) { long long ans = 0LL; a %= p; if (b <= 0LL) { return 1LL; } ans = power_mod(a, b/2LL, p); ans = (ans * ans) % p; if (b%2LL == 1LL) { ans = (ans * a) % p; } return ans; } void setup_ntt (int l) { int tmp_length = 4; log_l = 1; while(tmp_length < 2*l) { tmp_length *= 4; log_l++; } root = power_mod(root, length / tmp_length, mod_num); inverse_root = power_mod(root, mod_num-2LL, mod_num); inverse_l = power_mod((long long) tmp_length, mod_num-2LL, mod_num); length = tmp_length; pow_root[log_l-1] = root; for (int i = log_l-1; i > 0; i--) { pow_root[i-1] = pow_root[i]; pow_root[i-1] *= pow_root[i]; pow_root[i-1] %= mod_num; pow_root[i-1] *= pow_root[i-1]; pow_root[i-1] %= mod_num; } pow_root_inv[log_l-1] = inverse_root; for (int i = log_l-1; i > 0; i--) { pow_root_inv[i-1] = pow_root_inv[i]; pow_root_inv[i-1] *= pow_root_inv[i]; pow_root_inv[i-1] %= mod_num; pow_root_inv[i-1] *= pow_root_inv[i-1]; pow_root_inv[i-1] %= mod_num; } return; } void ntt_4n (long long *a, long long *pow_root) { long long root_1_4 = pow_root[0]; for (int i = 0; i < length; i++) { int idx = 0; int tmp = i; for (int j = 0; j < log_l; j++) { idx <<= 2; idx |= (tmp&3); tmp >>= 2; } if (i < idx) { long long swap = a[i]; a[i] = a[idx]; a[idx] = swap; } } for (int i = 0; i < log_l; i++) { int step = (1<<(2*i)); int stepx4 = (step<<2); int cnt = length/stepx4; long long tmp_root = 1LL; for (int j = 0; j < step; j++) { long long w1 = tmp_root; long long w2 = (w1*w1)%mod_num; long long w3 = (w2*w1)%mod_num; for (int k = 0; k < cnt; k++) { int idx1 = ((k*stepx4)|j); int idx2 = (idx1|step); int idx3 = (idx1|(2*step)); int idx4 = (idx2|idx3); long long a1 = a[idx1]; long long a2 = (a[idx2]*w1)%mod_num; long long a3 = (a[idx3]*w2)%mod_num; long long a4 = (a[idx4]*w3)%mod_num; long long wa2 = (a2*root_1_4)%mod_num; long long wa4 = (a4*root_1_4)%mod_num; long long pad = (mod_num<<1LL); a[idx1] = (a1+a2+a3+a4) % mod_num; a[idx2] = (a1+wa2-a3-wa4+pad) % mod_num; a[idx3] = (a1-a2+a3-a4+pad) % mod_num; a[idx4] = (a1-wa2-a3+wa4+pad) % mod_num; } tmp_root = (tmp_root*pow_root[i])%mod_num; } } return; } int main () { int n = 0; long long b = 0LL; long long c = 0LL; int res = 0; long long ans = 0LL; long long comb[60001] = {}; long long mul = 1LL; long long div = 1LL; long long cnt[60001] = {}; long long work[2][65536] = {}; res = scanf("%d", &n); res = scanf("%lld", &b); res = scanf("%lld", &c); for (int i = 0; i <= n; i++) { comb[i] = mul*power_mod(div, mod_num-2LL, mod_num); comb[i] %= mod_num; mul *= (long long) (n-i); mul %= mod_num; div *= (long long) (i+1); div %= mod_num; } setup_ntt((n+1)/2); cnt[0] = 1LL; for (int i = 0; i < 60; i++) { for (int j = 0; j < length; j++) { work[0][j] = 0LL; work[1][j] = 0LL; } if ((b&(1LL<<((long long)i))) > 0LL && (c&(1LL<<((long long)i))) > 0LL) { for (int j = 0; j <= n; j += 2) { work[0][j/2] = cnt[j]; } for (int k = 0; 2*k+1 <= n; k++) { work[1][k] = comb[2*k+1]; } } else if ((b&(1LL<<((long long)i))) > 0LL) { for (int j = 1; j <= n; j += 2) { work[0][j/2] = cnt[j]; } for (int k = 0; 2*k <= n; k++) { work[1][k] = comb[2*k]; } } else if ((c&(1LL<<((long long)i))) > 0LL) { for (int j = 1; j <= n; j += 2) { work[0][j/2] = cnt[j]; } for (int k = 0; 2*k+1 <= n; k++) { work[1][k] = comb[2*k+1]; } } else { for (int j = 0; j <= n; j += 2) { work[0][j/2] = cnt[j]; } for (int k = 0; 2*k <= n; k++) { work[1][k] = comb[2*k]; } } ntt_4n(work[0], pow_root); ntt_4n(work[1], pow_root); for (int j = 0; j < length; j++) { work[0][j] *= work[1][j]; work[0][j] %= mod_num; } ntt_4n(work[0], pow_root_inv); for (int j = 0; j <= n; j++) { cnt[j] = 0LL; } if ((b&(1LL<<((long long)i))) <= 0LL && (c&(1LL<<((long long)i))) > 0LL) { for (int j = 0; j < n; j++) { cnt[j+1] = (work[0][j]*inverse_l)%mod_num; } } else { for (int j = 0; j <= n; j++) { cnt[j] = (work[0][j]*inverse_l)%mod_num; } } } ans = cnt[0]; printf("%lld\n", ans); return 0; }