結果

問題 No.1237 EXP Multiple!
コンテスト
ユーザー y61mpnl
提出日時 2020-09-25 22:23:07
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,232 ms
コンパイル使用メモリ 209,092 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-14 00:42:25
合計ジャッジ時間 2,582 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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