結果

問題 No.16 累乗の加算
ユーザー flippergoflippergo
提出日時 2020-12-28 17:32:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 332 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 62,436 KB
最終ジャッジ日時 2024-04-14 11:06:06
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,140 KB
testcase_01 AC 36 ms
53,008 KB
testcase_02 AC 46 ms
62,436 KB
testcase_03 AC 36 ms
53,228 KB
testcase_04 AC 37 ms
52,864 KB
testcase_05 AC 37 ms
53,012 KB
testcase_06 AC 39 ms
54,588 KB
testcase_07 AC 37 ms
53,540 KB
testcase_08 AC 41 ms
58,904 KB
testcase_09 AC 45 ms
62,236 KB
testcase_10 AC 38 ms
53,756 KB
testcase_11 AC 37 ms
52,684 KB
testcase_12 AC 38 ms
52,664 KB
testcase_13 AC 38 ms
52,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = 10**6+3
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
x,N = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    n = A[i]
    ans = (ans+pow(x,n))%p
print(ans)
0