結果

問題 No.16 累乗の加算
コンテスト
ユーザー muscurry
提出日時 2024-06-10 17:01:10
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 352 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-10-10 05:57:50
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

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

def calc(base, exp, mod):
    res = 1
    while exp > 0:
        if exp % 2 == 1:
            res = (res * base) % mod
        base = (base * base) % mod
        exp //= 2
    return res

ans = 0
for a in A:
    temp = calc(x, a, MOD)
    ans += temp

print(ans % MOD)
0