結果

問題 No.2237 Xor Sum Hoge
ユーザー とりゐとりゐ
提出日時 2023-03-03 21:34:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 850 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 81,560 KB
実行使用メモリ 85,164 KB
最終ジャッジ日時 2023-10-18 01:29:26
合計ジャッジ時間 16,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
69,116 KB
testcase_01 AC 147 ms
84,540 KB
testcase_02 AC 136 ms
84,592 KB
testcase_03 AC 159 ms
85,164 KB
testcase_04 AC 148 ms
84,532 KB
testcase_05 AC 174 ms
84,800 KB
testcase_06 AC 157 ms
84,752 KB
testcase_07 AC 150 ms
84,576 KB
testcase_08 AC 176 ms
84,936 KB
testcase_09 AC 172 ms
84,804 KB
testcase_10 AC 173 ms
84,740 KB
testcase_11 AC 66 ms
69,112 KB
testcase_12 AC 66 ms
69,112 KB
testcase_13 AC 65 ms
69,112 KB
testcase_14 TLE -
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 #

mod=998244353
M=(10**5)*3+1 
fac=[1]*M
ninv=[1]*M
finv=[1]*M
for i in range(2,M):
  fac[i]=fac[i-1]*i%mod
  ninv[i]=(-(mod//i)*ninv[mod%i])%mod
  finv[i]=finv[i-1]*ninv[i]%mod

def binom(n,k):
  if n<0 or k<0:
    return 0
  if k>n:
    return 0
  return (fac[n]*finv[k]%mod)*finv[n-k]%mod

import random
hash=[random.randint(1,1<<60) for i in range(100)]
memo={}
def calc(R,k):
  if k<50:
    R=min(R,n*((1<<(k+1))-1))
  if k==-1:
    return 1
  if R^hash[k] in memo:
    return memo[R^hash[k]]
  x=1<<k
  res=0
  if (z>>k)&1:
    for i in range(1,min(n+1,R//x+1),2):
      res+=calc(R-x*i,k-1)*binom(n,i)%mod
  
  else:
    for i in range(0,min(n+1,R//x+1),2):
      res+=calc(R-x*i,k-1)*binom(n,i)%mod
  
  res%=mod
  memo[R^hash[k]]=res
  return res

n,b,z=map(int,input().split())
ans1=calc(b,59)
ans2=calc(b-1,59)
ans=(ans1-ans2)
print(ans%mod)
0