結果
| 問題 |
No.1084 積の積
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2020-06-20 03:27:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 896 bytes |
| コンパイル時間 | 2,414 ms |
| コンパイル使用メモリ | 221,496 KB |
| 最終ジャッジ日時 | 2025-01-11 08:26:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 25 TLE * 2 |
ソースコード
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const ll MOD=1e9+7;
const ll MAX=1e9;
ll modpow(ll x,ll n){
ll ans=1;
while(n){
if(n&1) ans=ans*x %MOD;
x=x*x %MOD;
n/=2;
}
return ans;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll> A(n);
rep(i,n) cin>>A[i];
rep(i,n){
if(A[i]==0){
cout<<0<<endl;
return 0;
}
}
vector<ll> B(n);
ll r=0;
ll x=1;
for(int i=0;i<n;i++){
for(int j=r;j<n && x*A[j]<MAX;j++){
x*=A[j];
r++;
}
B[i]=r;
x/=A[i];
}
vector<ll> C(n+1);
rep(i,n){
for(int j=i;j<B[i];j++) C[j]+=B[i]-j;
}
ll ans=1;
rep(i,n){
ans=ans*modpow(A[i],C[i])%MOD;
}
cout<<ans<<endl;
return 0;
}
umezo