結果

問題 No.1237 EXP Multiple!
ユーザー KKT89KKT89
提出日時 2020-09-26 06:57:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 204,928 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-09-11 01:58:23
合計ジャッジ時間 3,806 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 29 ms
4,376 KB
testcase_02 AC 40 ms
4,616 KB
testcase_03 AC 41 ms
4,664 KB
testcase_04 AC 30 ms
4,560 KB
testcase_05 AC 13 ms
4,572 KB
testcase_06 AC 17 ms
4,624 KB
testcase_07 AC 14 ms
4,688 KB
testcase_08 AC 17 ms
4,572 KB
testcase_09 AC 14 ms
4,560 KB
testcase_10 AC 14 ms
4,628 KB
testcase_11 AC 17 ms
4,568 KB
testcase_12 AC 17 ms
4,688 KB
testcase_13 AC 17 ms
4,560 KB
testcase_14 AC 17 ms
4,556 KB
testcase_15 AC 17 ms
4,568 KB
testcase_16 AC 17 ms
4,684 KB
testcase_17 AC 17 ms
4,688 KB
testcase_18 AC 17 ms
4,548 KB
testcase_19 AC 14 ms
4,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	bool zero=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(!a[i])zero=true;
	}
	if(zero){
		printf("-1\n");
	}
	else{
		sort(a.rbegin(), a.rend());
		if(a[0]>=4){
			printf("%lld\n",mod);
		}
		else{
			ll res=1;
			for(int i=0;i<n;i++){
				if(a[i]==3){
					for(int j=0;j<6;j++){
						res*=a[i];
						if(res>mod){
							printf("%lld\n",mod);
							return 0;
						}
					}
				}
				else if(a[i]==2){
					for(int j=0;j<2;j++){
						res*=a[i];
						if(res>mod){
							printf("%lld\n",mod);
							return 0;
						}
					}
				}
			}
			printf("%lld\n",mod%res);
		}
	}
}
0