結果

問題 No.16 累乗の加算
ユーザー tempura-samatempura-sama
提出日時 2016-04-19 10:17:12
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 366 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 56,528 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 03:42:49
合計ジャッジ時間 2,670 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

#define X 100
#define MOD 1000003

int n, x;
int m[X+1] = { 1, };

long long calc(int a)
{
	if ( m[a] == 0 ) {
		m[a] = (calc(a-1) * x) % MOD;
	}
	return m[a];
}

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

	int r = 0;
	for ( int i = 0; i < n; i++ ) {
		int a;
		cin >> a;
		r = (r + calc(a)) % MOD;
	}

	cout << r << endl;

	return 0;
}
0