結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cureskol
                         | 
                    
| 提出日時 | 2020-03-23 23:56:12 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 367 bytes | 
| コンパイル時間 | 1,998 ms | 
| コンパイル使用メモリ | 166,724 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-29 17:27:10 | 
| 合計ジャッジ時間 | 2,580 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1000003;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
signed main(){
  int x,n,ans=0;cin>>x>>n;
  while(n--){
    int a;cin>>a;
    ans+=pw(x,a);
  }
  cout<<ans%MOD<<endl;
}
            
            
            
        
            
cureskol