結果

問題 No.16 累乗の加算
ユーザー mannshi222jpmannshi222jp
提出日時 2022-02-12 18:30:53
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 28,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 06:29:21
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 530 ms
4,376 KB
testcase_03 AC 202 ms
4,376 KB
testcase_04 AC 257 ms
4,376 KB
testcase_05 AC 298 ms
4,376 KB
testcase_06 AC 367 ms
4,376 KB
testcase_07 AC 401 ms
4,376 KB
testcase_08 AC 472 ms
4,376 KB
testcase_09 AC 514 ms
4,376 KB
testcase_10 AC 504 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 524 ms
4,376 KB
testcase_13 AC 525 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

#define Z 1000003
int x, N;
long long int a;


int compare_int(const void *a, const void *b);

int main()
{
	int xn[100];
	long long int an[100];
	long long int sum = 0;
	long long int tmp;
	long long int ani;
	scanf("%d %d\n", &x, &N );

	for( int i = 0; i < N - 1 ; i++ ) {
		scanf("%lld ", an+i );
	}
	scanf("%lld\n", an+N-1 );

	qsort( an, N, sizeof( long long int) , compare_int );

	tmp = 1;
	ani = 0;
	for( int i = 0; i <= an[N-1]; i++ ) {
		if( i == an[ani] ) {
			sum += tmp;
			sum = sum %Z;
			ani++;
		}
		tmp = tmp * x;
		tmp = tmp % Z;
	}

	printf("%d\n", sum );


	return 0;
}

int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;
}
0