結果

問題 No.16 累乗の加算
ユーザー masamasa
提出日時 2015-01-22 19:51:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 62,452 KB
実行使用メモリ 394,036 KB
最終ジャッジ日時 2023-09-05 03:38:18
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,880 KB
testcase_01 AC 9 ms
7,052 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 WA -
testcase_12 WA -
testcase_13 AC 689 ms
390,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int MOD = 1000003;

int main() {
	int x, n;

	cin >> x >> n;
	vector<int> a(n);
	int maxi = MOD;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		maxi = max(maxi, a[i]);
	}

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = (ans + memo[a[i] % MOD]) % MOD;
	}

	cout << ans << endl;
	return 0;
}
0