結果

問題 No.16 累乗の加算
ユーザー Yut176Yut176
提出日時 2017-07-24 13:22:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 809 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 97,180 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 12:10:24
合計ジャッジ時間 1,599 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<random>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

// vector<long long int> b(101, -1);
long long int powmod(long long int a, long long int p, long long int m){
  if( p == 0 ) return 1;
  if( p % 2 == 0 ) return powmod(a, p/2, m)%m * powmod(a, p/2, m)%m;
  else return a%m * powmod(a, p-1, m)%m;
}

int main(void) {

  long long int x, n;
  cin >> x >> n;
  vector<long long int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  long long int sum = 0;
  for(int i=0; i<n; i++){
    sum += powmod(x, a[i], 1000003);
    sum %= 1000003;
  }
  cout << sum << endl;

  return 0;
}
0