結果
問題 | No.2097 AND^k |
ユーザー | chro_96 |
提出日時 | 2022-11-14 01:04:33 |
言語 | C (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,082 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 33,152 KB |
実行使用メモリ | 17,516 KB |
最終ジャッジ日時 | 2024-09-15 06:14:06 |
合計ジャッジ時間 | 69,866 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
17,408 KB |
testcase_01 | AC | 5 ms
17,408 KB |
testcase_02 | AC | 7 ms
17,408 KB |
testcase_03 | AC | 7 ms
17,464 KB |
testcase_04 | AC | 7 ms
17,480 KB |
testcase_05 | AC | 7 ms
17,432 KB |
testcase_06 | AC | 5 ms
17,408 KB |
testcase_07 | AC | 6 ms
17,408 KB |
testcase_08 | AC | 4,226 ms
17,408 KB |
testcase_09 | AC | 929 ms
17,388 KB |
testcase_10 | AC | 4,608 ms
17,396 KB |
testcase_11 | AC | 878 ms
17,408 KB |
testcase_12 | AC | 783 ms
17,408 KB |
testcase_13 | AC | 4,637 ms
17,408 KB |
testcase_14 | AC | 4,487 ms
17,408 KB |
testcase_15 | TLE | - |
testcase_16 | AC | 4,306 ms
17,516 KB |
testcase_17 | AC | 4,919 ms
17,408 KB |
testcase_18 | AC | 4,571 ms
17,408 KB |
testcase_19 | AC | 4,187 ms
17,512 KB |
testcase_20 | AC | 4,057 ms
17,280 KB |
testcase_21 | AC | 4,172 ms
17,512 KB |
testcase_22 | AC | 4,384 ms
17,408 KB |
testcase_23 | AC | 4,420 ms
17,408 KB |
testcase_24 | AC | 5 ms
17,516 KB |
testcase_25 | TLE | - |
ソースコード
#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 root, 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 cnt = length/(4*step); 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++) { long long a1 = a[4*k*step+j]; long long a2 = (a[(4*k+1)*step+j]*w1)%mod_num; long long a3 = (a[(4*k+2)*step+j]*w2)%mod_num; long long a4 = (a[(4*k+3)*step+j]*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[4*k*step+j] = (a1+a2+a3+a4) % mod_num; a[(4*k+1)*step+j] = (a1+wa2-a3-wa4+pad) % mod_num; a[(4*k+2)*step+j] = (a1-a2+a3-a4+pad) % mod_num; a[(4*k+3)*step+j] = (a1-wa2-a3+wa4+pad) % mod_num; } tmp_root = (tmp_root*pow_root[i])%mod_num; } } return; } int main () { int n = 0; int m = 0; int l = 0; int res = 0; long long ans[600000] = {}; long long work[2][600000] = {}; long long pow2 = 2LL; long long fact[100001] = {}; long long invf[100001] = {}; long long inv_cnt = 0LL; long long pow_cnt = 0LL; long long pow_inv_l = 0LL; res = scanf("%d", &n); res = scanf("%d", &m); res = scanf("%d", &l); fact[0] = 1LL; for (int i = 0; i < l; i++) { fact[i+1] = fact[i]; fact[i+1] *= (long long) (i+1); fact[i+1] %= mod_num; } invf[l] = power_mod(fact[l], mod_num-2LL, mod_num); for (int i = l; i > 0; i--) { invf[i-1] = invf[i]; invf[i-1] *= (long long)i; invf[i-1] %= mod_num; } setup_ntt(l+1); work[0][0] = power_mod(2LL, (long long)n, mod_num); for (int i = 1; i <= l; i++) { work[0][i] = invf[i]; } for (int i = 0; i <= l; i++) { work[1][i] = work[0][i]; } ntt_4n(work[1], root, pow_root); if (m%2 == 1) { for (int i = 0; i <= l; i++) { ans[i] = work[0][i]; } } else { ans[0] = 1LL; } m /= 2; while (m > 0) { long long p = 1LL; for (int j = 0; j <= l; j++) { work[0][j] *= p; work[0][j] %= mod_num; p = (p*pow2)%mod_num; } ntt_4n(work[0], root, pow_root); for (int j = 0; j < length; j++) { work[0][j] *= work[1][j]; work[0][j] %= mod_num; } ntt_4n(work[0], inverse_root, pow_root_inv); for (int j = 0; j <= l; j++) { work[1][j] = work[0][j]; } for (int j = l+1; j < length; j++) { work[0][j] = 0LL; work[1][j] = 0LL; } pow_cnt = 2LL*pow_cnt+1LL; ntt_4n(work[1], root, pow_root); pow2 = (pow2*pow2)%mod_num; if (m%2 == 1) { long long p = 1LL; for (int i = 0; i <= l; i++) { ans[i] *= p; ans[i] %= mod_num; p = (p*pow2)%mod_num; } for (int i = l+1; i < length; i++) { ans[i] = 0LL; } ntt_4n(ans, root, pow_root); for (int i = 0; i < length; i++) { ans[i] *= work[1][i]; ans[i] %= mod_num; } ntt_4n(ans, inverse_root, pow_root_inv); inv_cnt += pow_cnt+1LL; } m /= 2; } pow_inv_l = power_mod(inverse_l, inv_cnt, mod_num); for (int i = 0; i < l; i++) { printf("%lld\n", (((ans[i+1]*pow_inv_l)%mod_num)*fact[i+1])%mod_num); } return 0; }