結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kutsutama
                         | 
                    
| 提出日時 | 2018-03-11 01:37:08 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,177 ms / 5,000 ms | 
| コード長 | 508 bytes | 
| コンパイル時間 | 214 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 14,592 KB | 
| 最終ジャッジ日時 | 2024-06-26 05:26:48 | 
| 合計ジャッジ時間 | 8,831 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
ソースコード
x, n = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
mod = 1000003
big = 100000
xx = [0] * (big + 1)
xx[0] = 1
for e in range(1, big + 1):
    xx[e] = xx[e - 1] * x % mod
res = 0
for ai in a:
    if ai > big:
        prod = 1
        for e in range(ai // big):
            prod = prod * xx[big] % mod
        for e in range(ai % big):
            prod = prod * x % mod
        res = (res + prod) % mod
    else:
        res = (res + xx[ai]) % mod
print(res)
            
            
            
        
            
kutsutama