結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ytft
                         | 
                    
| 提出日時 | 2022-11-03 05:31:27 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 45 ms / 5,000 ms | 
| コード長 | 344 bytes | 
| コンパイル時間 | 151 ms | 
| コンパイル使用メモリ | 82,228 KB | 
| 実行使用メモリ | 58,496 KB | 
| 最終ジャッジ日時 | 2024-07-17 16:23:14 | 
| 合計ジャッジ時間 | 1,749 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
ソースコード
import sys
input=lambda:sys.stdin.readline().rstrip()
def p(a,p,mod):
    rem=p%(mod-1)
    temp=a
    ans=1
    while rem:
        if rem%2:
            ans=(ans*temp)%mod
        temp=(temp**2)%mod
        rem//=2
    return ans
mod=1000003
x,N=map(int,input().split())
a=list(map(int,input().split()))
print(sum([p(x,i,mod) for i in a])%mod)
            
            
            
        
            
ytft