結果
| 問題 | No.1084 積の積 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-20 08:01:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| コード長 | 969 bytes |
| 記録 | |
| コンパイル時間 | 1,533 ms |
| コンパイル使用メモリ | 98,984 KB |
| 最終ジャッジ日時 | 2025-01-11 08:30:13 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <cstdio>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const ll mx=1e9;
constexpr ll mod=1e9+7;
ll mod_pow(ll a,ll b){
a%=mod;
if(b==0)return 1;
if(b==1)return a;
ll res=mod_pow(a,b/2)%mod;
res*=res; res%=mod;
if(b%2)res*=a;
return res%mod;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n; cin >> n;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
}
ll m1=1,m2=1,r=0,ans=1LL;
for(int l=0;l<n;l++){
while(r<n&&m1*a[r]<mx){
m1*=a[r];
m2*=m1;
m2%=mod;
r++;
}
(ans*=m2)%=mod;
(m1*=mod_pow(a[l],mod-2))%=mod;
(m2*=mod_pow(mod_pow(a[l],mod-2),r-l))%=mod;
}
cout << ans << endl;
}