結果

問題 No.16 累乗の加算
ユーザー kutsutama
提出日時 2018-03-11 01:27:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 573 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 56,664 KB
最終ジャッジ日時 2024-10-15 00:01:37
合計ジャッジ時間 7,688 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

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