結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-10-22 00:06:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 733 bytes |
| コンパイル時間 | 2,720 ms |
| コンパイル使用メモリ | 278,540 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-22 00:06:21 |
| 合計ジャッジ時間 | 4,899 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
constexpr ll m = 1'000'000'007;
if (*min_element(a.begin(), a.end()) == 0) {
cout << -1 << '\n';
}
else if (*max_element(a.begin(), a.end()) >= 4) {
cout << m << '\n';
}
else {
ll p = 1;
rep(i, n) {
if (a[i] == 1) p *= 1;
if (a[i] == 2) p *= 2 * 2;
if (a[i] == 3) p *= 3 * 3 * 3 * 3 * 3 * 3;
if (p > m) {
cout << m << '\n';
return 0;
}
}
cout << m % p << '\n';
}
return 0;
}
a01sa01to