結果

問題 No.16 累乗の加算
ユーザー prog470prog470
提出日時 2016-09-24 14:21:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 543 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 1,827 ms
コンパイル使用メモリ 72,220 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 12:01:57
合計ジャッジ時間 6,902 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 543 ms
4,380 KB
testcase_03 AC 209 ms
4,380 KB
testcase_04 AC 266 ms
4,380 KB
testcase_05 AC 307 ms
4,384 KB
testcase_06 AC 379 ms
4,376 KB
testcase_07 AC 415 ms
4,376 KB
testcase_08 AC 487 ms
4,376 KB
testcase_09 AC 532 ms
4,376 KB
testcase_10 AC 523 ms
4,376 KB
testcase_11 AC 543 ms
4,380 KB
testcase_12 AC 541 ms
4,380 KB
testcase_13 AC 540 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

long long dp[100000005] = {};

int main() {

	long long MOD = 1000003, x, N, a[105], ans = 0;
	cin >> x >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a,a+N);
	long long cnt = 1;

	for (int j = 0; j < a[0]; j++) {
		cnt = cnt * x % MOD;
	}
	ans = cnt;
	//cout << 0 << ": " << cnt << endl;

	for (int i = 1; i < N; i++) {
		for (int j = a[i-1]; j < a[i]; j++) {
			cnt = cnt * x % MOD;
		}
		//cout <<i<< ": " << cnt << endl;
		ans = (ans + cnt) % MOD;
	}

	cout << ans << endl;

	return 0;
}
0