結果

問題 No.1237 EXP Multiple!
ユーザー y61mpnly61mpnl
提出日時 2020-09-25 22:23:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 197,956 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-09-10 15:38:05
合計ジャッジ時間 3,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 AC 27 ms
4,380 KB
testcase_03 AC 27 ms
4,384 KB
testcase_04 AC 28 ms
4,512 KB
testcase_05 AC 17 ms
4,376 KB
testcase_06 AC 16 ms
4,544 KB
testcase_07 AC 16 ms
4,384 KB
testcase_08 AC 17 ms
4,384 KB
testcase_09 AC 16 ms
4,380 KB
testcase_10 AC 16 ms
4,380 KB
testcase_11 AC 17 ms
4,460 KB
testcase_12 WA -
testcase_13 AC 17 ms
4,388 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 17 ms
4,384 KB
testcase_17 AC 17 ms
4,380 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 AC 16 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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