結果

問題 No.16 累乗の加算
ユーザー ibukitiibukiti
提出日時 2021-10-19 12:30:31
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 434 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 835,144 KB
最終ジャッジ日時 2023-10-20 10:45:01
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,408 KB
testcase_01 AC 39 ms
53,408 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

x,n=map(int,input().split())
a=list(map(int,input().split()))
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x
dp=[0]*(max(a)+1)
ans=0
mod=1000003
for i in a:
    ans+=pow_k(x,i)
    ans%=mod

print(ans)
0