結果

問題 No.16 累乗の加算
ユーザー nebukuro09nebukuro09
提出日時 2016-09-21 13:49:03
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 369 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 76,800 KB
実行使用メモリ 264,068 KB
最終ジャッジ日時 2024-04-28 16:44:33
合計ジャッジ時間 7,343 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

MOD = 1000003
mem = {}
X, N = map(int, raw_input().split())
a = map(int, raw_input().split())

def power(x, n):
    if n in mem:
        return mem[(x, n)]
    if n == 0:
        return 1
    if n%2 == 0:
        mem[(x, n)] = power(x*x, n/2) % MOD
    else:
        mem[(x, n)] = x * power(x, n-1) % MOD
    return mem[(x, n)]

print sum(map(lambda n:power(X, n), a))
0