結果

問題 No.16 累乗の加算
ユーザー toyuzuko
提出日時 2020-03-10 22:50:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 387 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-15 23:50:49
合計ジャッジ時間 1,298 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

def power(base, exp, op=lambda x, y: x * y, ie=1):
    res = ie
    while exp:
        if exp & 1:
            res = op(res, base)
        base = op(base, base)
        exp >>= 1
    return res

x, N = map(int, input().split())
A = list(map(int, input().split()))

op = lambda x, y: x * y % 1000003
ans = 0

for i in range(N):
    ans += power(x, A[i], op, 1)

ans %= 1000003

print(ans)
0