結果

問題 No.2394 部分和乗総和
ユーザー nikoro256nikoro256
提出日時 2023-07-28 22:15:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 475 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 93,040 KB
最終ジャッジ日時 2024-04-16 06:13:45
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,712 KB
testcase_01 AC 44 ms
51,968 KB
testcase_02 AC 43 ms
52,096 KB
testcase_03 AC 43 ms
51,712 KB
testcase_04 AC 44 ms
52,096 KB
testcase_05 AC 44 ms
52,224 KB
testcase_06 AC 45 ms
52,096 KB
testcase_07 AC 44 ms
51,840 KB
testcase_08 AC 49 ms
57,856 KB
testcase_09 AC 48 ms
57,344 KB
testcase_10 AC 50 ms
58,112 KB
testcase_11 AC 50 ms
58,752 KB
testcase_12 AC 44 ms
51,968 KB
testcase_13 AC 113 ms
76,416 KB
testcase_14 AC 215 ms
80,128 KB
testcase_15 AC 226 ms
81,024 KB
testcase_16 AC 286 ms
84,144 KB
testcase_17 AC 475 ms
92,544 KB
testcase_18 AC 473 ms
93,040 KB
testcase_19 AC 473 ms
92,800 KB
testcase_20 AC 424 ms
92,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def exp(a,b,p):
    ans,mul,div=1,a,1
    for i in range(70):
        if b//div%2==1:
            ans*=mul
            ans%=p
        mul=mul**2%p
        div*=2
    return ans%p

N,M,B=map(int,input().split())
A=list(map(int,input().split()))
ans=1
for i in range(N):
    ans+=ans*exp(M,A[i],B)
    ans%=B
print(ans)
0