結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2016-11-18 18:32:39 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 5,000 ms |
コード長 | 522 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 54,616 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-06-26 05:18:17 |
合計ジャッジ時間 | 1,192 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <iostream>using namespace std;typedef long long ll;#define REP(i,f,l) for(int i=f;i<l;i++)const ll devider = 1000003;ll x, n;ll table[devider];int main(){cin >> x >> n;x %= devider;table[0] = 1;REP(i,1,devider) {table[i] = (table[i-1]*x) % devider;}int sum = 0;int val;int count = 0;REP(i,0,n){cin >> val;count++;//1000003は素数なのでフェルマーの小定理を利用するsum += table[val%(devider-1)];}cout<<sum % devider<<endl;}