結果

問題 No.16 累乗の加算
ユーザー ytftytft
提出日時 2022-11-03 05:31:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 344 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 75,900 KB
最終ジャッジ日時 2023-09-24 15:36:54
合計ジャッジ時間 2,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,396 KB
testcase_01 AC 72 ms
71,376 KB
testcase_02 AC 77 ms
75,624 KB
testcase_03 AC 73 ms
71,368 KB
testcase_04 AC 74 ms
71,200 KB
testcase_05 AC 74 ms
71,332 KB
testcase_06 AC 76 ms
75,708 KB
testcase_07 AC 74 ms
71,268 KB
testcase_08 AC 76 ms
75,572 KB
testcase_09 AC 78 ms
75,900 KB
testcase_10 AC 76 ms
75,696 KB
testcase_11 AC 72 ms
71,492 KB
testcase_12 AC 73 ms
71,440 KB
testcase_13 AC 73 ms
71,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
def p(a,p,mod):
    rem=p%(mod-1)
    temp=a
    ans=1
    while rem:
        if rem%2:
            ans=(ans*temp)%mod
        temp=(temp**2)%mod
        rem//=2
    return ans
mod=1000003
x,N=map(int,input().split())
a=list(map(int,input().split()))
print(sum([p(x,i,mod) for i in a])%mod)
0