結果
| 問題 | No.2237 Xor Sum Hoge |
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-03-03 23:16:56 |
| 言語 | C (gcc 15.2.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,254 bytes |
| 記録 | |
| コンパイル時間 | 1,326 ms |
| コンパイル使用メモリ | 32,000 KB |
| 実行使用メモリ | 10,396 KB |
| 最終ジャッジ日時 | 2024-09-18 00:24:48 |
| 合計ジャッジ時間 | 23,027 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 31 |
ソースコード
#include <stdio.h>
long long power_mod (long long a, long long b, long long mod_num) {
long long ans = 1LL;
if (b > 0LL) {
ans = power_mod(a, b/2LL, mod_num);
ans = (ans * ans) % mod_num;
if (b%2LL == 1LL) {
ans = (ans * (a % mod_num)) % mod_num;
}
}
return ans;
}
int main () {
int n = 0;
long long b = 0LL;
long long c = 0LL;
int res = 0;
long long ans = 0LL;
long long mod_num = 998244353LL;
long long comb[60001] = {};
long long mul = 1LL;
long long div = 1LL;
long long cnt[60001] = {};
long long tmp[120002] = {};
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;
}
cnt[0] = 1LL;
for (int i = 0; i < 60; i++) {
for (int j = 0; j <= 2*n; j++) {
tmp[j] = 0LL;
}
if ((b&(1LL<<((long long)i))) > 0LL && (c&(1LL<<((long long)i))) > 0LL) {
for (int j = 0; j <= n; j += 2) {
if (cnt[j] > 0LL) {
for (int k = 0; 2*k+1 <= n; k++) {
tmp[2*k+1+j] += cnt[j]*comb[2*k+1];
tmp[2*k+1+j] %= mod_num;
}
}
}
} else if ((b&(1LL<<((long long)i))) > 0LL) {
for (int j = 1; j <= n; j += 2) {
if (cnt[j] > 0LL) {
for (int k = 0; 2*k <= n; k++) {
tmp[2*k+j] += cnt[j]*comb[2*k];
tmp[2*k+j] %= mod_num;
}
}
}
} else if ((c&(1LL<<((long long)i))) > 0LL) {
for (int j = 1; j <= n; j += 2) {
if (cnt[j] > 0LL) {
for (int k = 0; 2*k+1 <= n; k++) {
tmp[2*k+1+j] += cnt[j]*comb[2*k+1];
tmp[2*k+1+j] %= mod_num;
}
}
}
} else {
for (int j = 0; j <= n; j += 2) {
if (cnt[j] > 0LL) {
for (int k = 0; 2*k <= n; k++) {
tmp[2*k+j] += cnt[j]*comb[2*k];
tmp[2*k+j] %= mod_num;
}
}
}
}
for (int i = 0; i <= n; i++) {
cnt[i] = (tmp[2*i]+tmp[2*i+1])%mod_num;
}
}
ans = cnt[0];
printf("%lld\n", ans);
return 0;
}
chro_96