結果

問題 No.16 累乗の加算
ユーザー masa
提出日時 2015-01-22 15:54:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 959 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 61,384 KB
実行使用メモリ 393,656 KB
最終ジャッジ日時 2024-06-26 04:48:49
合計ジャッジ時間 8,699 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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