結果

問題 No.16 累乗の加算
ユーザー kutsutamakutsutama
提出日時 2018-03-11 01:27:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 573 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 56,752 KB
最終ジャッジ日時 2024-04-23 00:50:13
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 316 ms
49,892 KB
testcase_01 AC 332 ms
49,884 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 #

x, n = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
mod = 1000003

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

print(res)
0