結果

問題 No.1237 EXP Multiple!
ユーザー chocorusk
提出日時 2020-09-25 21:29:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 121,984 KB
最終ジャッジ日時 2025-01-14 20:36:41
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int f[]={1, 1, 2, 6, 120};
int main()
{
    int n; cin>>n;
    ll ans=1;
    const ll INF=1e9+10;
    for(int i=0; i<n; i++){
        ll a; cin>>a;
        if(a==0){
            cout<<-1<<endl;
            return 0;
        }else if(a==1) continue;
        int m=100;
        if(a<=4) m=f[a];
        for(int j=0; j<m; j++){
            ans=min(INF, ans*a);
        }
    }
    cout<<MOD%ans<<endl;
	return 0;
}
0