結果

問題 No.16 累乗の加算
ユーザー Naoyk1212Naoyk1212
提出日時 2016-10-14 21:58:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 157,660 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 23:07:31
合計ジャッジ時間 2,057 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

long long pow_mod(long long n, long long p, long long m){
	if (p == 0){
		return 1;
	}else if(p % 2 == 1){
		return pow_mod(n, p - 1, m) * n % m;
	}else{
		long long t = pow_mod(n, p / 2, m);
		return t * t % m;
	}
}

int main(){
  int x, n;
  cin >> x >> n;
  long long ans = 0;
  int a;
  for(int i = 0; i < n; i++){
    cin >> a;
    ans += pow_mod(x, a, 1e6 + 3);
  }
  cout << ans << endl;
}
0