結果

問題 No.1237 EXP Multiple!
ユーザー Example0911Example0911
提出日時 2020-09-26 14:30:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 166,864 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-11 11:17:18
合計ジャッジ時間 3,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 55 ms
4,376 KB
testcase_02 AC 74 ms
4,708 KB
testcase_03 AC 76 ms
4,644 KB
testcase_04 AC 83 ms
4,584 KB
testcase_05 AC 30 ms
4,588 KB
testcase_06 AC 30 ms
4,620 KB
testcase_07 AC 31 ms
4,580 KB
testcase_08 AC 30 ms
4,640 KB
testcase_09 AC 30 ms
4,876 KB
testcase_10 AC 30 ms
4,556 KB
testcase_11 AC 30 ms
4,716 KB
testcase_12 AC 30 ms
4,640 KB
testcase_13 AC 30 ms
4,536 KB
testcase_14 AC 30 ms
4,588 KB
testcase_15 AC 30 ms
4,616 KB
testcase_16 AC 30 ms
4,580 KB
testcase_17 AC 30 ms
4,624 KB
testcase_18 AC 30 ms
4,560 KB
testcase_19 AC 30 ms
4,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;
using P = pair<int, int>;

signed main() {
	int N; cin >> N;
	vector<ll>A(N); for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) {
			cout << -1 << endl; return 0;
		}
	}
	ll now = 1;
	for (int i = 0; i < N; i++) {
		if (now >= mod) {
			cout << mod << endl; return 0;
		}
		if (A[i] == 1) {
			
		}
		else if (A[i] == 2) {
			now *= 4;
		}
		else if (A[i] == 3) {
			now *= 3 * 3 * 3 * 3 * 3 * 3;
		}
		else {
			cout << mod << endl; return 0;
		}
	}
	if (now >= mod) {
		cout << mod << endl; return 0;
	}
	cout << mod % now << endl;
	return 0;
}
0