結果

問題 No.1084 積の積
ユーザー SSRSSSRS
提出日時 2020-06-19 22:09:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 893 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 166,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 14:29:45
合計ジャッジ時間 4,151 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 44 ms
4,376 KB
testcase_05 RE -
testcase_06 AC 44 ms
4,376 KB
testcase_07 RE -
testcase_08 AC 2 ms
4,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 25 ms
4,380 KB
testcase_13 AC 50 ms
4,376 KB
testcase_14 AC 20 ms
4,380 KB
testcase_15 AC 19 ms
4,376 KB
testcase_16 AC 57 ms
4,380 KB
testcase_17 AC 23 ms
4,380 KB
testcase_18 AC 38 ms
4,380 KB
testcase_19 AC 51 ms
4,376 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 19 ms
4,376 KB
testcase_22 AC 15 ms
4,376 KB
testcase_23 AC 32 ms
4,376 KB
testcase_24 AC 28 ms
4,376 KB
testcase_25 AC 51 ms
4,380 KB
testcase_26 AC 41 ms
4,380 KB
testcase_27 AC 41 ms
4,376 KB
testcase_28 AC 41 ms
4,376 KB
testcase_29 AC 41 ms
4,380 KB
testcase_30 AC 41 ms
4,376 KB
testcase_31 AC 41 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
long long modpow(long long a, long long b){
	a %= MOD;
	long long res = 1;
	while (b > 0){
		if (b % 2 == 1) res = res * a % MOD;
		a = a * a % MOD;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int R = 0;
  long long ans = 1;
  long long curr = 1;
  long long tmp = 1;
  for (int L = 0; L < N; L++){
    while (1){
      if (R == N){
        break;
      }
      if (curr * A[R] >= INF){
        break;
      }
      curr *= A[R];
      R++;
      tmp *= curr;
      tmp %= MOD;
    }
    ans *= tmp;
    ans %= MOD;
    curr /= A[L];
    tmp *= modpow(modinv(A[L]), R - L);
    tmp %= MOD;
  }
  cout << ans << endl;
}
0