結果

問題 No.1237 EXP Multiple!
ユーザー y61mpnl
提出日時 2020-09-25 22:23:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 191,532 KB
最終ジャッジ日時 2025-01-14 21:05:01
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

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