結果

問題 No.1237 EXP Multiple!
ユーザー nok0nok0
提出日時 2020-08-25 21:44:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 4,908 ms
コンパイル使用メモリ 200,248 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 17:21:11
合計ジャッジ時間 3,635 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 53 ms
4,376 KB
testcase_02 AC 72 ms
4,380 KB
testcase_03 AC 74 ms
4,376 KB
testcase_04 AC 80 ms
4,380 KB
testcase_05 AC 29 ms
4,376 KB
testcase_06 AC 29 ms
4,380 KB
testcase_07 AC 31 ms
4,376 KB
testcase_08 AC 30 ms
4,376 KB
testcase_09 AC 28 ms
4,380 KB
testcase_10 AC 29 ms
4,376 KB
testcase_11 AC 29 ms
4,376 KB
testcase_12 AC 30 ms
4,380 KB
testcase_13 AC 30 ms
4,376 KB
testcase_14 AC 30 ms
4,376 KB
testcase_15 AC 31 ms
4,376 KB
testcase_16 AC 30 ms
4,380 KB
testcase_17 AC 31 ms
4,376 KB
testcase_18 AC 30 ms
4,376 KB
testcase_19 AC 28 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

int d[4] = {1, 1, 2, 6};
const int MOD = 1e9 + 7;

int main(){
    int n; 
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    REP(i, n) if(!a[i]){
        cout << -1 << endl;
        return 0;
    }
    long long mul = 1;
    REP(i, n){
        if(a[i] >= 4){
            cout << MOD << endl;
            return 0;
        }
        mul *= pow(a[i], d[a[i]]);
        if(mul > MOD){
            cout << MOD << endl;
            return 0;
        }
    }
    cout << MOD % mul << endl;
}
0