結果

問題 No.16 累乗の加算
ユーザー Kutimoti_TKutimoti_T
提出日時 2017-12-19 17:06:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 839 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 52,148 KB
実行使用メモリ 394,064 KB
最終ジャッジ日時 2023-09-08 12:12:06
合計ジャッジ時間 9,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 839 ms
393,828 KB
testcase_03 AC 282 ms
152,992 KB
testcase_04 AC 355 ms
193,192 KB
testcase_05 AC 420 ms
223,616 KB
testcase_06 AC 533 ms
275,464 KB
testcase_07 AC 593 ms
301,188 KB
testcase_08 AC 735 ms
353,056 KB
testcase_09 AC 760 ms
383,996 KB
testcase_10 AC 756 ms
377,488 KB
testcase_11 AC 791 ms
394,064 KB
testcase_12 AC 780 ms
391,800 KB
testcase_13 AC 787 ms
390,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

#define MOD(N) ((N) % 1000003)
#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

int dp[100000000];

int N;
int x;

int max_ = 0;

int a[100];

int main()
{
	cin >> x >> N;
	FOR(i,0,N -1)
	{
		cin >> a[i];
		max_ = max(max_,a[i]);
	}
	dp[0] = 1;
	FOR(i,1,max_)
	{
		dp[i] = MOD(dp[i - 1] * x);
	}
	int res = 0;
	FOR(i,0,N-1)
	{
		res = MOD(res + dp[a[i]]);
	}
	cout << res << endl;
	return 0;
	
}	
0