結果

問題 No.16 累乗の加算
ユーザー suppy193suppy193
提出日時 2016-11-02 11:38:26
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 676 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 24,692 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 12:02:48
合計ジャッジ時間 1,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main(void) {
	long long int x, n;
	long long int a[101];
	long long int i, j;
	long long int total = 0;
	long long int subtotal, an;
	
	scanf("%lld%lld", &x, &n);
	for(i = 1;i <= n;i++){
		scanf("%lld", &a[i]);
	}
	for(i = 1;i <= n;i++){
		subtotal= 1;
		an = x;
		while(a[i] != 0){
			//printf("a[%lld] = %lld %lld\n", i, a[i], an);
			if(a[i] % 2 == 1){
				subtotal = (subtotal * an) % 1000003;
			}
		//for(j = 0;j < a[i];j++){
			an = (an * an) % 1000003;
			a[i] /= 2;
		}
		//printf("subtotal = %lld\n", subtotal);
		total = (total + subtotal) % 1000003;
	}
	//printf("total = %lld\n", total % 1000003);
	printf("%lld\n", total);
	
	return 0;
}
0