結果

問題 No.16 累乗の加算
ユーザー masamasa
提出日時 2015-01-22 15:54:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 857 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 62,712 KB
実行使用メモリ 393,940 KB
最終ジャッジ日時 2023-09-08 11:31:54
合計ジャッジ時間 8,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 857 ms
393,480 KB
testcase_03 AC 253 ms
152,352 KB
testcase_04 AC 339 ms
192,900 KB
testcase_05 AC 374 ms
223,260 KB
testcase_06 AC 494 ms
275,140 KB
testcase_07 AC 506 ms
300,748 KB
testcase_08 AC 629 ms
352,676 KB
testcase_09 AC 646 ms
383,628 KB
testcase_10 AC 633 ms
377,148 KB
testcase_11 AC 659 ms
393,940 KB
testcase_12 AC 658 ms
391,660 KB
testcase_13 AC 652 ms
390,236 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 = 0;
	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;
	}

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