結果

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

ソースコード

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