結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2022-01-22 15:36:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 2,000 ms |
| コード長 | 711 bytes |
| コンパイル時間 | 477 ms |
| コンパイル使用メモリ | 63,616 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 12:54:29 |
| 合計ジャッジ時間 | 1,977 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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];
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;
}
startcpp