結果

問題 No.2237 Xor Sum Hoge
ユーザー とりゐとりゐ
提出日時 2023-03-03 21:30:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 81,512 KB
実行使用メモリ 96,492 KB
最終ジャッジ日時 2023-10-18 01:24:10
合計ジャッジ時間 13,747 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
69,064 KB
testcase_01 AC 112 ms
83,532 KB
testcase_02 AC 106 ms
83,824 KB
testcase_03 AC 112 ms
83,712 KB
testcase_04 AC 109 ms
83,824 KB
testcase_05 AC 123 ms
83,752 KB
testcase_06 AC 109 ms
83,824 KB
testcase_07 AC 110 ms
83,676 KB
testcase_08 AC 122 ms
83,764 KB
testcase_09 AC 118 ms
83,716 KB
testcase_10 AC 128 ms
83,736 KB
testcase_11 AC 65 ms
69,060 KB
testcase_12 AC 65 ms
69,060 KB
testcase_13 AC 65 ms
69,060 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
H=[random.randint(1,1<<50) for i in range(100)]
def hash(L,R,k):
  return H[k]^(L+R)

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

n,b,z=map(int,input().split())
#n,l,r,z=map(int,input().split())
print(calc(b,b,59))
0