結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-04-08 18:13:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 862 bytes |
| コンパイル時間 | 1,995 ms |
| コンパイル使用メモリ | 194,880 KB |
| 最終ジャッジ日時 | 2025-02-20 23:10:53 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll modc = 1e9+7;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//A=0ならA^{A!} = 0^1 = 0
ll N, ans=1;
cin >> N;
vector<ll> A(N);
//答えが1e9+7を超えたら1e9+7
//A=1で1,A=2で4, A=3で729, 4以上は考えない
for (int i=0; i<N; i++){
cin >> A[i];
if (A[i] == 0){
cout << -1 << endl;
return 0;
}
}
for (int i=0; i<N; i++){
if (A[i] >= 4){
cout << modc << endl;
return 0;
}
if (A[i] == 1) ans *= 1;
if (A[i] == 2) ans *= 4;
if (A[i] == 3) ans *= 729;
if (ans > modc){
cout << modc << endl;
return 0;
}
}
cout << modc % ans << endl;
return 0;
}
srjywrdnprkt