結果

問題 No.2396 等差二項展開
ユーザー convexineqconvexineq
提出日時 2023-08-01 20:36:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 78,976 KB
最終ジャッジ日時 2024-04-19 19:51:06
合計ジャッジ時間 9,918 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,712 KB
testcase_01 AC 36 ms
52,352 KB
testcase_02 AC 31 ms
51,968 KB
testcase_03 AC 32 ms
51,712 KB
testcase_04 AC 32 ms
51,328 KB
testcase_05 AC 33 ms
51,712 KB
testcase_06 AC 33 ms
51,712 KB
testcase_07 AC 32 ms
52,096 KB
testcase_08 AC 34 ms
51,584 KB
testcase_09 AC 32 ms
51,840 KB
testcase_10 AC 34 ms
52,224 KB
testcase_11 AC 33 ms
51,584 KB
testcase_12 AC 34 ms
51,712 KB
testcase_13 AC 38 ms
59,264 KB
testcase_14 AC 37 ms
58,880 KB
testcase_15 AC 41 ms
60,800 KB
testcase_16 AC 201 ms
75,776 KB
testcase_17 AC 724 ms
77,824 KB
testcase_18 AC 1,132 ms
78,976 KB
testcase_19 AC 548 ms
76,672 KB
testcase_20 AC 33 ms
51,968 KB
testcase_21 AC 34 ms
51,968 KB
testcase_22 WA -
testcase_23 AC 585 ms
76,928 KB
testcase_24 AC 403 ms
75,776 KB
testcase_25 AC 1,069 ms
78,080 KB
testcase_26 AC 463 ms
76,032 KB
testcase_27 AC 414 ms
76,408 KB
testcase_28 AC 1,029 ms
78,080 KB
testcase_29 AC 405 ms
76,160 KB
testcase_30 AC 706 ms
76,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def polymul(f,g):
    lg = len(g)
    h = [0]*(len(f)+lg-1)
    for i,v in enumerate(f):
        for j in range(lg):
            h[i+j] += v*g[j]
            h[i+j] %= MOD
    
    for i in range(L,len(h)):
        h[i-L] += h[i]*M
        h[i-L] %= MOD
    return h[:L]

"""
(1+x)^n mod (x^n-M)
"""
n,M,L,k,MOD = map(int,input().split())

ans = [1]+[0]*(L-1)
p = [1,1]
while n:
    if n%2:
        ans = polymul(ans,p)
    p = polymul(p,p)
    n //= 2
print(ans[k])

0