結果

問題 No.16 累乗の加算
ユーザー ReERishunReERishun
提出日時 2020-05-14 08:07:09
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 913 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 29,224 KB
実行使用メモリ 6,080 KB
最終ジャッジ日時 2023-10-12 22:38:44
合計ジャッジ時間 6,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,352 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<string.h>

typedef unsigned int u_int;
typedef unsigned long long u_long2;

// 入力関数
void numin(int index, int *numBox) {
	char str;
	for (int i = 0; i<index; i++)
		numBox[i] = 0;
	int cnt = 0;
	while (cnt < index) {
		str = getchar();
		if (str == '\n') {
			if (cnt != 0)
				break;
		}
		else if (str < '0' || str > '9')
			cnt++;
		else
			numBox[cnt] = numBox[cnt] * 10 + (int)str - (int)'0';
	}
}


// 累乗関数
u_long2 rr_exponen(u_int radix, int index) {
	u_long2 ans = 1;
	for (int i = 0; i < index; i++) {
		ans *= radix;
		if (ans >= 1000003)
			ans %= 1000003;
	}
	return ans;
}


int main() {
	u_long2	ans = 0;
	u_int	radix = 0;
	u_int	number = 0;
	u_int	index[100];

	scanf("%u %u", &radix, &number);

	numin(number, index);

	for (u_int i = 0; i < number; i++) 
		ans += rr_exponen(radix, index[i]);

	printf("%llu", ans);
		// 終了コードは0
	return 0;
}
0