結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,260 KB
testcase_01 AC 39 ms
53,260 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)%mod
dp=[0]*(max(a)+1)
ans=0
mod=1000003
for i in a:
    ans+=pow_k(x,i)


print(ans%mod)
0