結果

問題 No.1084 積の積
ユーザー auauaauaua
提出日時 2020-06-19 22:36:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,542 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 166,636 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-09-16 14:51:09
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 37 ms
5,512 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 36 ms
5,368 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 36 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 18 ms
4,380 KB
testcase_13 AC 37 ms
5,204 KB
testcase_14 AC 14 ms
4,380 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 42 ms
5,456 KB
testcase_17 AC 17 ms
4,380 KB
testcase_18 AC 27 ms
4,580 KB
testcase_19 AC 37 ms
5,196 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 23 ms
4,404 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 37 ms
5,076 KB
testcase_26 AC 26 ms
5,480 KB
testcase_27 AC 25 ms
5,512 KB
testcase_28 AC 25 ms
5,412 KB
testcase_29 AC 25 ms
5,320 KB
testcase_30 AC 25 ms
5,280 KB
testcase_31 AC 25 ms
5,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%inf;
        x=x*x%inf;
        b/=2;
    }
    return res;
}
signed main(){
    ll n;cin>>n;
    vector<ll>a(n+1);
    a[n]=1;
    bool f=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0)f=1;
    }
    if(f){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    vector<ll>imos(n+2);
    vector<ll>imo(n+2);
    ll j=0;
    ll now=1;
    rep(i,n){
        if(j==n){
            imos[i]+=j-i;
            imo[i+1]--;
            imo[j+1]++;
        }else{
            while(j<n&&a[j]*now<1000000000LL){
                now*=a[j];
                j++;
            }

                imos[i]+=j-i;
                imo[i+1]--;
                imo[j+1]++;
        }
        now/=a[i];
    }
    REP(i,1,n+2){
        imo[i]+=imo[i-1];
        //cout<<imo[i]<<endl;
    }
    REP(i,1,n+1){
        imos[i]+=imos[i-1]+imo[i];
    }
    rep(i,n){
        //cout<<imos[i]<<endl;
    }
    rep(i,n){
        ans=(ans*rui(a[i],imos[i])%inf)%inf;
    }
    cout<<ans<<endl;
}
0