結果
| 問題 | No.1237 EXP Multiple! |
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-09-25 23:26:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 2,340 ms |
| コンパイル使用メモリ | 193,624 KB |
| 最終ジャッジ日時 | 2025-01-14 21:40:17 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
const int x[4] = { 0, 1, 4, 729 };
int n;
cin >> n;
vector<int> a(n);
bool big = false;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 0) {
cout << -1 << endl;
return 0;
}
if (a[i] >= 4) {
big = true;
}
}
if (big) {
cout << 1000000007 << endl;
return 0;
}
int64_t p = 1;
for (int i = 0; i < n; i++) {
p *= x[a[i]];
if (p >= 1000000007) {
cout << 1000000007 << endl;
return 0;
}
}
cout << 1000000007 % p << endl;
}
trineutron