結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-25 22:21:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,130 bytes |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 82,548 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 06:44:48 |
| 合計ジャッジ時間 | 2,438 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 WA * 5 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define endl "\n"
const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007;
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}
long long power(long long x, long long n){
long long ans = 1;
int N = n;
if(x == 0) return 1;
if(x >= 4) return -1;
n = 1;
for(int i = 1; i <= N; i++){
n *= i;
}
// cout<<"n = "<<n<<endl;
for(;n;n >>= 1, x *= x) {
if(n&1)ans*=x;
if(ans > MOD) return -1;
}
return ans;
}
signed main(){
int N;
int zero = 0;
int ans = 1;
vector<int> A;
cin>>N;
A.resize(N);
for(int i = 0; i < N; i++){
cin>>A[i];
// if(A[i] == 0)zero++;
}
// if(zero == 1) {
// cout<<-1<<endl;
// return 0;
// }
for(int i = 0; i < N; i++){
int t = power(A[i], A[i]);
if(t == -1) {
cout<<MOD<<endl;
return 0;
}
ans *= t;
if(ans > MOD) {
// cout<<"ans"<<" "<<ans<<endl;
cout<<MOD<<endl;
return 0;
}
}
cout<<MOD%ans<<endl;
return 0;
}