結果

問題 No.1084 積の積
ユーザー ateate
提出日時 2020-06-20 00:39:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 203,760 KB
実行使用メモリ 5,796 KB
最終ジャッジ日時 2023-09-16 16:18:57
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 AC 38 ms
5,408 KB
testcase_07 RE -
testcase_08 AC 2 ms
4,380 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 20 ms
4,380 KB
testcase_13 AC 38 ms
5,236 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 14 ms
4,376 KB
testcase_16 AC 44 ms
5,476 KB
testcase_17 AC 18 ms
4,376 KB
testcase_18 AC 30 ms
4,680 KB
testcase_19 AC 39 ms
5,416 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 12 ms
4,376 KB
testcase_23 AC 24 ms
4,376 KB
testcase_24 AC 22 ms
4,380 KB
testcase_25 AC 39 ms
5,224 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll = int64_t;
ll mod_pow(ll n,ll p,ll MOD){
  ll ans=1LL;
  while(p){
    if(p&1)ans*=n;
    n*=n;
    p>>=1;
    ans%=MOD;
    n%=MOD;
  }
  return ans;
}


signed main(){

  int n;
  cin>>n;
  vector a(n,0ll);
  for(auto& ai:a)cin>>ai;

  int64_t tmp = 1;
  const int64_t inf = 1e9;
  vector<int64_t> kl(n),kr(n);
  int l=0,r=0;
  for(;l<n;++l){
    while(r<n && tmp*a[r]<inf)tmp*=a[r++];
    kl[l] = r-l;
    tmp /= a[l];
  }
  reverse(begin(a),end(a));
  l=0,r=0;
  for(;l<n;++l){
    while(r<n && tmp*a[r]<inf)tmp*=a[r++];
    kr[l] = r-l;
    tmp /= a[l];
  }
  reverse(begin(kr),end(kr));
  reverse(begin(a),end(a));

  const int64_t MOD = 1e9+7;
  int64_t ans = 1;
  for(int i=0;i<n;++i){
    ans *= mod_pow(a[i],(kl[i]*kr[i]),MOD);
    ans %= MOD;
  }
  cout<<(ans)<<endl;


}
0