結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-04 22:50:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 963 bytes |
| コンパイル時間 | 466 ms |
| コンパイル使用メモリ | 63,980 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-19 06:13:39 |
| 合計ジャッジ時間 | 1,942 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
//答え「で」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];
// 答えが0なら-1を返す(お約束)
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;
}