結果

問題 No.2396 等差二項展開
ユーザー とりゐとりゐ
提出日時 2023-07-28 22:21:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 73,216 KB
最終ジャッジ日時 2024-04-16 06:19:24
合計ジャッジ時間 10,231 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,968 KB
testcase_01 AC 44 ms
52,096 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 41 ms
52,224 KB
testcase_04 AC 50 ms
59,136 KB
testcase_05 AC 42 ms
52,352 KB
testcase_06 AC 42 ms
51,840 KB
testcase_07 AC 50 ms
59,776 KB
testcase_08 AC 53 ms
61,056 KB
testcase_09 AC 41 ms
51,712 KB
testcase_10 AC 42 ms
52,096 KB
testcase_11 AC 42 ms
51,968 KB
testcase_12 WA -
testcase_13 AC 58 ms
62,080 KB
testcase_14 AC 58 ms
62,336 KB
testcase_15 AC 75 ms
65,408 KB
testcase_16 AC 207 ms
68,352 KB
testcase_17 AC 611 ms
71,552 KB
testcase_18 AC 863 ms
73,216 KB
testcase_19 AC 1,006 ms
73,088 KB
testcase_20 AC 42 ms
52,224 KB
testcase_21 AC 43 ms
51,840 KB
testcase_22 WA -
testcase_23 AC 464 ms
70,016 KB
testcase_24 AC 711 ms
71,552 KB
testcase_25 AC 858 ms
72,960 KB
testcase_26 AC 648 ms
71,424 KB
testcase_27 AC 710 ms
71,680 KB
testcase_28 AC 777 ms
72,448 KB
testcase_29 AC 710 ms
71,680 KB
testcase_30 AC 521 ms
70,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(a,b):
  c=[0]*L
  for i in range(L):
    for j in range(L):
      if i+j>=L:
        c[(i+j)%L]+=a[i]*b[j]%mod*M
      else:
        c[(i+j)]+=a[i]*b[j]%mod
      c[(i+j)%L]%=mod
  return c

N,M,L,K,mod=map(int,input().split())
M%=mod
ans=[0]*L
ans[0]=1
tmp=[0]*L
tmp[0]=1
tmp[1%L]+=1

for i in range(60):
  if (N>>i)&1:
    ans=f(ans,tmp)
  tmp=f(tmp,tmp)

print(ans[K]%mod)
0