結果

問題 No.2396 等差二項展開
ユーザー tassei903tassei903
提出日時 2023-07-28 22:43:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,609 ms / 6,000 ms
コード長 1,097 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-04-16 06:42:08
合計ジャッジ時間 26,054 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 39 ms
52,096 KB
testcase_04 AC 40 ms
52,096 KB
testcase_05 AC 40 ms
52,480 KB
testcase_06 AC 39 ms
52,096 KB
testcase_07 AC 41 ms
52,352 KB
testcase_08 AC 41 ms
52,224 KB
testcase_09 AC 43 ms
52,400 KB
testcase_10 AC 39 ms
52,096 KB
testcase_11 AC 39 ms
52,352 KB
testcase_12 AC 39 ms
52,352 KB
testcase_13 AC 62 ms
66,432 KB
testcase_14 AC 61 ms
66,688 KB
testcase_15 AC 84 ms
73,088 KB
testcase_16 AC 488 ms
76,288 KB
testcase_17 AC 2,090 ms
76,332 KB
testcase_18 AC 3,195 ms
76,676 KB
testcase_19 AC 3,609 ms
77,312 KB
testcase_20 AC 40 ms
52,096 KB
testcase_21 AC 41 ms
52,608 KB
testcase_22 AC 40 ms
52,096 KB
testcase_23 AC 1,663 ms
77,056 KB
testcase_24 AC 2,558 ms
76,608 KB
testcase_25 AC 1,353 ms
76,276 KB
testcase_26 AC 931 ms
77,188 KB
testcase_27 AC 2,479 ms
76,928 KB
testcase_28 AC 1,785 ms
76,632 KB
testcase_29 AC 2,443 ms
76,544 KB
testcase_30 AC 1,417 ms
76,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n,m,l,k,b = na()

if l == 1:
    print(pow(1+m, n, b))
    exit()

a = [0] * l
a[0] = 1 % b
a[1] = 1 % b

f = [0] * l
f[0] = 1
#print(f, a)
while n:
    if n % 2:
        nf = [0] * l
        for i in range(l):
            for j in range(l):
                if i+j >= l:
                    nf[i+j-l] += f[i] * a[j] % b * m % b
                else:
                    nf[i+j] += f[i] * a[j] % b
                nf[(i+j)%l] %= b
        f = nf
    na = [0] * l
    for i in range(l):
        for j in range(l):
            if i+j >= l:
                na[i+j-l] += a[i] * a[j] % b * m % b
            else:
                na[i+j] += a[i] * a[j] % b
            na[(i+j)%l] %= b
    a = na
    #print(f, a)
    n//=2
#print(f)
print(f[k] % b)
0