結果

問題 No.1084 積の積
ユーザー auauaauaua
提出日時 2020-06-19 22:29:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,529 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 167,028 KB
実行使用メモリ 5,660 KB
最終ジャッジ日時 2023-09-16 14:44:54
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 16 ms
4,376 KB
testcase_06 AC 37 ms
5,512 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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){
                j++;
                now*=a[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