結果

問題 No.16 累乗の加算
ユーザー DialBirdDialBird
提出日時 2016-11-18 18:32:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 52,132 KB
実行使用メモリ 11,260 KB
最終ジャッジ日時 2023-09-08 12:03:34
合計ジャッジ時間 1,372 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
11,148 KB
testcase_01 AC 10 ms
11,204 KB
testcase_02 AC 11 ms
11,200 KB
testcase_03 AC 10 ms
11,200 KB
testcase_04 AC 11 ms
11,208 KB
testcase_05 AC 10 ms
11,164 KB
testcase_06 AC 10 ms
11,124 KB
testcase_07 AC 10 ms
11,200 KB
testcase_08 AC 10 ms
11,224 KB
testcase_09 AC 10 ms
11,124 KB
testcase_10 AC 10 ms
11,152 KB
testcase_11 AC 10 ms
11,160 KB
testcase_12 AC 10 ms
11,148 KB
testcase_13 AC 10 ms
11,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0