結果
| 問題 |
No.1084 積の積
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-20 00:50:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 971 bytes |
| コンパイル時間 | 849 ms |
| コンパイル使用メモリ | 100,300 KB |
| 最終ジャッジ日時 | 2025-01-11 08:19:21 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 WA * 1 |
ソースコード
#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<int> 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;
}