結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2017-03-11 02:20:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 70,428 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:21:50 |
合計ジャッジ時間 | 1,249 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include<iostream> #include<vector> using namespace std; const int BIG = 1000003; long pow(long n, int r){ if(r==0) return 1; if(r%2 == 0) return pow((n*n)%BIG, r/2); else return (n*pow(n, r-1))%BIG; } int main(){ int x, n; cin >> x >> n; vector<int> v(n); for(int i=0; i<n; i++)cin >> v[i]; long sum =0; for(int i=0; i<n; i++){ sum += pow(x, v[i]); sum = sum % BIG; //cout << pow(x, v[i]) << endl; } cout << sum << endl; }