結果

問題 No.16 累乗の加算
ユーザー krotonkroton
提出日時 2015-02-04 05:35:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 143,948 KB
実行使用メモリ 7,560 KB
最終ジャッジ日時 2023-09-08 11:31:45
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,548 KB
testcase_01 AC 9 ms
7,244 KB
testcase_02 AC 9 ms
7,248 KB
testcase_03 AC 10 ms
7,256 KB
testcase_04 AC 9 ms
7,248 KB
testcase_05 AC 9 ms
7,560 KB
testcase_06 AC 9 ms
7,376 KB
testcase_07 AC 9 ms
7,312 KB
testcase_08 AC 9 ms
7,312 KB
testcase_09 AC 10 ms
7,248 KB
testcase_10 AC 10 ms
7,456 KB
testcase_11 AC 9 ms
7,292 KB
testcase_12 AC 9 ms
7,452 KB
testcase_13 AC 9 ms
7,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MOD = 1000003;
int pows[MOD + 10];

int main(){
	int x; cin >> x;

	pows[0] = 1;
	for(int i=1;i<MOD-1;i++){
		pows[i] = (pows[i-1] * x) % MOD;
	}

	int N; cin >> N;
	int res = 0;

	while(N--){
		int a; cin >> a;

		res += pows[a % (MOD - 1)];
		if(res >= MOD)
			res -= MOD;
	}

	cout << res << endl;
	return 0;
}
0