結果

問題 No.1237 EXP Multiple!
ユーザー y61mpnly61mpnl
提出日時 2020-09-25 22:45:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 198,680 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-09-10 15:58:35
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 20 ms
4,852 KB
testcase_02 AC 27 ms
5,060 KB
testcase_03 AC 28 ms
5,044 KB
testcase_04 AC 29 ms
5,052 KB
testcase_05 AC 17 ms
4,968 KB
testcase_06 AC 17 ms
5,180 KB
testcase_07 AC 17 ms
5,084 KB
testcase_08 AC 17 ms
5,348 KB
testcase_09 AC 17 ms
5,152 KB
testcase_10 AC 17 ms
5,056 KB
testcase_11 AC 17 ms
5,148 KB
testcase_12 AC 17 ms
5,048 KB
testcase_13 AC 18 ms
5,056 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 17 ms
5,032 KB
testcase_17 AC 17 ms
5,116 KB
testcase_18 AC 17 ms
5,112 KB
testcase_19 AC 17 ms
5,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b;i<e;i++)
using ll = int_fast64_t;
const ll MOD = 1e9+7;

int main(){
    ll n;
    scanf("%ld", &n);
    ll a[n], zero = 0, huge = 0;
    REP(i, 0, n){
        scanf("%ld", &a[i]);
        if(a[i]==0) zero++;
        if(a[i]>3) huge++;
    }

    if(zero) puts("-1");
    else if(huge) printf("%ld\n", MOD);
    else{
        ll ans = 1;
        REP(i, 0, n){
            REP(j, 1, a[i]+1){
                REP(k, 0, j){
                    ans *= a[i];
                    if(ans>MOD){
                        printf("%ld\n", MOD);
                        return 0;
                    }
                }
            }
        }
        printf("%ld\n", MOD%ans);
    }
    return 0;
}
0