結果

問題 No.1237 EXP Multiple!
ユーザー nawawannawawan
提出日時 2020-09-25 22:16:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,123 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 70,456 KB
実行使用メモリ 4,812 KB
最終ジャッジ日時 2023-09-10 17:26:15
合計ジャッジ時間 2,020 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 AC 26 ms
4,620 KB
testcase_03 AC 26 ms
4,656 KB
testcase_04 AC 28 ms
4,600 KB
testcase_05 AC 14 ms
4,620 KB
testcase_06 AC 14 ms
4,556 KB
testcase_07 AC 14 ms
4,752 KB
testcase_08 AC 14 ms
4,620 KB
testcase_09 AC 14 ms
4,536 KB
testcase_10 AC 14 ms
4,572 KB
testcase_11 AC 15 ms
4,812 KB
testcase_12 AC 15 ms
4,540 KB
testcase_13 AC 15 ms
4,640 KB
testcase_14 AC 15 ms
4,556 KB
testcase_15 AC 15 ms
4,652 KB
testcase_16 AC 14 ms
4,656 KB
testcase_17 AC 14 ms
4,660 KB
testcase_18 AC 14 ms
4,584 KB
testcase_19 AC 14 ms
4,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const int MAX = 410000;
const int MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int flag = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == 0) flag = 1;
    }
    if(flag == 1){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        if(A[i] >= 4) flag = 1;
    }
    if(flag == 1){
        cout << MOD << endl;
        return 0;
    }
    vector<long long> kai(4);
    for(int i = 0; i < 4; i++){
        if(i == 0) kai[i] = 1;
        else kai[i] = kai[i - 1] * i;
    }
    long long temp = 1;
    for(int i = 0; i < N; i++){
        long long res = 1;
        long long cnt = kai[A[i]];
        long long x = A[i];
        while(cnt > 0){
            if(cnt & 1) res *= x;
            x = x * x;
            cnt >>= 1;
        }
        temp *= res;
        if(temp > MOD){
            cout << MOD << endl;
            return 0;
        }
    }
    cout << MOD % temp << endl;
}
0