結果

問題 No.1084 積の積
ユーザー iqueue02iqueue02
提出日時 2020-06-19 22:48:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 201,584 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-09-16 15:03:13
合計ジャッジ時間 10,279 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 TLE -
testcase_05 RE -
testcase_06 TLE -
testcase_07 RE -
testcase_08 AC 2 ms
4,380 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 37 ms
4,428 KB
testcase_14 AC 15 ms
4,376 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 41 ms
4,692 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 27 ms
4,380 KB
testcase_19 AC 37 ms
4,376 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 23 ms
4,380 KB
testcase_24 AC 20 ms
4,376 KB
testcase_25 AC 36 ms
4,380 KB
testcase_26 AC 26 ms
4,632 KB
testcase_27 AC 26 ms
4,604 KB
testcase_28 AC 26 ms
4,752 KB
testcase_29 AC 26 ms
4,636 KB
testcase_30 AC 26 ms
4,604 KB
testcase_31 AC 26 ms
4,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod =  1e9 + 7;
constexpr int INF = 1e9;
ll mod_pow(ll x, ll n, ll mod){
    if(n == 0)return 1;
    ll res = mod_pow(x*x%mod,n/2,mod);
    if(n&1) res = res * x % mod;
    return res;
}
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> cnt(n, 0);

  ll res = 1;

  int r = 0;
  ll now = 1;

  for (int l = 0; l < n; l++) {
    while (r < n && now * a[r] < INF) {
      now *= a[r];
      r++;
    }
    int len = r - l;
    for (int i = l; i < r; i++) {
      cnt[i] += len;
      len--;
    }
    now /= a[l];
  }
  for (int i = 0; i < n; i++) {
    res *= mod_pow(a[i], cnt[i], mod);
    res %= mod;
  }
 
  cout << res << endl;
  return 0;
} 
0