結果

問題 No.1084 積の積
ユーザー KKT89KKT89
提出日時 2020-06-20 00:50:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 102,916 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 16:20:10
合計ジャッジ時間 3,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 61 ms
4,376 KB
testcase_06 AC 62 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 48 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 37 ms
4,376 KB
testcase_14 AC 14 ms
4,380 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 42 ms
4,376 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 27 ms
4,376 KB
testcase_19 AC 38 ms
4,376 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 12 ms
4,384 KB
testcase_23 AC 23 ms
4,376 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 37 ms
4,376 KB
testcase_26 AC 38 ms
4,376 KB
testcase_27 AC 38 ms
4,380 KB
testcase_28 AC 39 ms
4,376 KB
testcase_29 AC 39 ms
4,380 KB
testcase_30 AC 39 ms
4,376 KB
testcase_31 AC 40 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0