結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-10 17:01:10 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 31 ms / 5,000 ms | 
| コード長 | 352 bytes | 
| コンパイル時間 | 192 ms | 
| コンパイル使用メモリ | 11,904 KB | 
| 実行使用メモリ | 10,368 KB | 
| 最終ジャッジ日時 | 2025-01-02 10:31:28 | 
| 合計ジャッジ時間 | 1,277 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
ソースコード
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)