結果

問題 No.2237 Xor Sum Hoge
ユーザー 👑 chro_96chro_96
提出日時 2023-03-03 23:16:56
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 2,254 bytes
コンパイル時間 1,337 ms
コンパイル使用メモリ 32,620 KB
実行使用メモリ 12,396 KB
最終ジャッジ日時 2023-10-18 03:35:04
合計ジャッジ時間 24,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0