結果

問題 No.16 累乗の加算
ユーザー shisyamokongarishisyamokongari
提出日時 2016-09-29 18:00:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 529 ms / 5,000 ms
コード長 407 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 61,936 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 12:02:12
合計ジャッジ時間 6,546 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 529 ms
4,376 KB
testcase_03 AC 204 ms
4,376 KB
testcase_04 AC 258 ms
4,376 KB
testcase_05 AC 298 ms
4,376 KB
testcase_06 AC 369 ms
4,376 KB
testcase_07 AC 403 ms
4,376 KB
testcase_08 AC 475 ms
4,376 KB
testcase_09 AC 518 ms
4,380 KB
testcase_10 AC 507 ms
4,376 KB
testcase_11 AC 528 ms
4,380 KB
testcase_12 AC 525 ms
4,376 KB
testcase_13 AC 524 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

#define NMAX 100
#define MOD 1000003

int main(){

	int x,N;
	int cnt=0;
	long long a[NMAX];
	long long ans=0;
	long long xa=1;
	long long xc=0;
	cin>>x;
	cin>>N;
	for(int i=0;i<N;i++) cin>>a[i];

	sort(a,a+N);

	while(cnt<N){
		while(cnt<N&&a[cnt]==xc){
			ans+=xa;
			ans%=MOD;
			cnt++;
		}
		xa*=x;
		xa%=MOD;
		xc++;
	}
	cout<<ans<<endl;
}
0