結果
| 問題 |
No.1084 積の積
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2020-06-19 22:21:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,408 bytes |
| コンパイル時間 | 1,477 ms |
| コンパイル使用メモリ | 170,012 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 14:57:47 |
| 合計ジャッジ時間 | 3,642 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 RE * 1 |
| other | AC * 2 WA * 22 RE * 3 |
ソースコード
#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;
rep(i,n)cin>>a[i];
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<1e9){
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;
}
auaua