結果

問題 No.1237 EXP Multiple!
ユーザー pengin_2000pengin_2000
提出日時 2020-09-25 21:57:31
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 28,840 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 17:25:41
合計ジャッジ時間 2,875 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,384 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 AC 27 ms
4,380 KB
testcase_03 AC 28 ms
4,380 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 16 ms
4,380 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 17 ms
4,376 KB
testcase_10 AC 16 ms
4,384 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 17 ms
4,376 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 17 ms
4,380 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 17 ms
4,384 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int fact(long long int i)
{
	long long int res = 1;
	for (; i > 0; i--)
		res *= i;
	return res;
}
long long int f(long long int i)
{
	long long int res = 1;
	long long int n = fact(i);
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * i;
		i = i * i;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i;
	long long int a[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int p = 1000000007;
	for (i = 0; i < n; i++)
	{
		if (a[i] == 0)
		{
			printf("-1\n");
			return 0;
		}
	}
	long long int res = 1;
	for (i = 0; i < n; i++)
	{
		if (a[i] > 3)
			res = 1000000009;
		else
			res = res * f(a[i]);
		if (res > p)
			break;
	}
	printf("%lld\n", p % res);
	return 0;
}
0