結果

問題 No.1237 EXP Multiple!
ユーザー startcppstartcpp
提出日時 2022-01-22 15:36:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 63,264 KB
実行使用メモリ 4,996 KB
最終ジャッジ日時 2023-08-18 09:02:21
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 56 ms
4,444 KB
testcase_02 AC 74 ms
4,848 KB
testcase_03 AC 76 ms
4,932 KB
testcase_04 AC 83 ms
4,880 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 30 ms
4,892 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 30 ms
4,884 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 30 ms
4,892 KB
testcase_12 AC 31 ms
4,876 KB
testcase_13 AC 30 ms
4,880 KB
testcase_14 AC 30 ms
4,996 KB
testcase_15 AC 31 ms
4,908 KB
testcase_16 AC 31 ms
4,880 KB
testcase_17 AC 31 ms
4,900 KB
testcase_18 AC 31 ms
4,908 KB
testcase_19 AC 30 ms
4,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//答え「で」10^9 + 7を割った余りなので、答え > 10^9 + 7 なら速攻で0を返してOK。
//注意点 A = [ ... 4 0 ... ] のケースでは、mod ではなくて -1 を返す必要がある。
#include <iostream>
#define int long long
using namespace std;

int mod = 1000000007;
int n;
int a[200000];

signed main() {
	int i;
	
	int ans = 1;
	
	cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) { cout << -1 << endl; return 0; }
	}
	for (i = 0; i < n; i++) {
		if (a[i] >= 4) { cout << mod << endl; return 0; }
		if (a[i] == 2) { ans *= 4; }
		if (a[i] == 3) { ans *= 729; }
		if (ans > mod) { cout << mod << endl; return 0; }
	}
	
	cout << mod % ans << endl;
	return 0;
}
0