結果

問題 No.16 累乗の加算
ユーザー C_kumoC_kumo
提出日時 2019-01-22 23:40:22
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 29,424 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 09:20:08
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define ANS (1000000+3)

int main(void)
{
	char x,n,g,h,i,j;
	int a,tmp,ans=0;
	scanf("%hhd %hhd",&x,&n);
	for (i=0;i<n;i++) {
		scanf("%d",&a);
		
		g = a / 4;
		h = a % 4;
		tmp = 1;
		for (j=0;j<g;j++) {
			tmp *= pow(x,4);
			tmp = tmp % ANS;
		}
		tmp *= pow(x,h);
		tmp = tmp % ANS;
		ans += tmp;
		ans = ans % ANS;
	}

	printf("%d\n",ans);
	
	return 0;
}
0