結果

問題 No.16 累乗の加算
ユーザー C_kumoC_kumo
提出日時 2019-01-22 23:51:39
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 29,132 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-14 09:20:17
合計ジャッジ時間 6,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define ANS (1000000+3)
#define DEV 3

#define DEBUG 0

int main(void)
{
	char x,n,i;
	long a,g,h,j,tmp,ans=0;
	scanf("%hhd %hhd",&x,&n);
	for (i=0;i<n;i++) {
		scanf("%ld",&a);
		
		g = a / DEV;
		h = a % DEV;
		tmp = 1;
		if (DEBUG) printf("g=%ld\n",g);
		for (j=0;j<g;j++) {
			tmp *= pow(x,DEV);
			tmp = tmp % ANS;
		}
		tmp *= pow(x,h);
		tmp = tmp % ANS;

		if (DEBUG) printf("%hhd ^ %ld = %ld\n",x,a,tmp);
		ans += tmp;
		ans = ans % ANS;
	}

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