結果
問題 | No.1237 EXP Multiple! |
ユーザー | ok |
提出日時 | 2020-09-25 22:39:31 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 1,411 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 4,916 KB |
最終ジャッジ日時 | 2023-09-10 17:28:27 |
合計ジャッジ時間 | 2,597 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | AC | 55 ms
4,380 KB |
testcase_02 | AC | 74 ms
4,768 KB |
testcase_03 | AC | 76 ms
4,740 KB |
testcase_04 | AC | 83 ms
4,744 KB |
testcase_05 | AC | 30 ms
4,624 KB |
testcase_06 | AC | 30 ms
4,684 KB |
testcase_07 | AC | 31 ms
4,612 KB |
testcase_08 | AC | 31 ms
4,576 KB |
testcase_09 | AC | 30 ms
4,740 KB |
testcase_10 | AC | 30 ms
4,628 KB |
testcase_11 | AC | 30 ms
4,584 KB |
testcase_12 | AC | 31 ms
4,584 KB |
testcase_13 | AC | 31 ms
4,916 KB |
testcase_14 | AC | 31 ms
4,632 KB |
testcase_15 | AC | 31 ms
4,620 KB |
testcase_16 | AC | 31 ms
4,624 KB |
testcase_17 | AC | 31 ms
4,676 KB |
testcase_18 | AC | 32 ms
4,624 KB |
testcase_19 | AC | 30 ms
4,624 KB |
ソースコード
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> using namespace std; #define int __int128 #define endl "\n" const long long INF = (long long)1e18; const int 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(){ long long N; int zero = 0; int ans = 1; vector<long long> 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) { if(ans == 0){ cout<<-1<<endl; return 0; } cout<<(long long)MOD<<endl; return 0; } ans *= t; if(ans > MOD) { // exit(2); if(ans == 0){ cout<<-1<<endl; return 0; } cout<<(long long)MOD<<endl; return 0; } } if(ans == 0){ cout<<-1<<endl; return 0; } long long hoge = (MOD%((long long)ans)); cout<<hoge<<endl; return 0; if(hoge != 0) { // exit(2); cout<<hoge<<endl; } else cout<<-1<<endl; return 0; }