結果

問題 No.16 累乗の加算
ユーザー kutsutamakutsutama
提出日時 2018-03-11 01:22:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 539 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 819,800 KB
最終ジャッジ日時 2024-04-23 00:50:02
合計ジャッジ時間 3,553 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
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 = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
mod = 1000003

xx = [0] * 100000001
xx[0] = 1
for e in range(1, 1000000 + 1):
    xx[e] = xx[e - 1] * x % mod
res = 0
for ai in a:
    if xx[ai] == 0:
        d = ai // 1000000 * 1000000
        for e in range(1, ai // 1000000 + 1):
            xx[(e + 1) * 1000000] = xx[e * 1000000] * xx[1000000] % mod
        for e in range(1, ai % 1000000 + 1):
            xx[d + e] = xx[d + e - 1] * x % mod
    res = (res + xx[ai]) % mod

print(res)
0