結果

問題 No.1237 EXP Multiple!
ユーザー 👑 NachiaNachia
提出日時 2020-09-27 20:27:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 166,952 KB
実行使用メモリ 4,532 KB
最終ジャッジ日時 2023-09-13 02:14:27
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 65 ms
4,376 KB
testcase_02 AC 87 ms
4,380 KB
testcase_03 AC 89 ms
4,380 KB
testcase_04 AC 83 ms
4,376 KB
testcase_05 AC 32 ms
4,380 KB
testcase_06 AC 36 ms
4,380 KB
testcase_07 AC 34 ms
4,376 KB
testcase_08 AC 33 ms
4,380 KB
testcase_09 AC 32 ms
4,380 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 35 ms
4,380 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 33 ms
4,464 KB
testcase_14 AC 33 ms
4,452 KB
testcase_15 AC 34 ms
4,380 KB
testcase_16 AC 34 ms
4,380 KB
testcase_17 AC 34 ms
4,376 KB
testcase_18 AC 34 ms
4,532 KB
testcase_19 AC 32 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
int A[200000];
ULL M = 1000000007;

int main() {
	cin >> N;
	rep(i, N) cin >> A[i];
	sort(A, A + N);
	if (A[0] == 0) { cout << -1 << endl; return 0; }
	if (A[N - 1] >= 4) { cout << M << endl; return 0; }
	ULL T[4] = { 0,1,4,729 };
	ULL ans = 1;
	double L = 0;
	rep(i, N) { ans *= T[A[i]]; L += log(T[A[i]]); }
	if (L >= log(1.e10) || ans > M) cout << M << endl;
	else cout << (M % ans) << endl;
	return 0;
}
0