結果

問題 No.1084 積の積
ユーザー hirokazu1020hirokazu1020
提出日時 2020-06-19 22:04:10
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,437 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 92,744 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 14:22:54
合計ジャッジ時間 3,631 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 RE -
testcase_06 AC 18 ms
4,376 KB
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 36 ms
4,380 KB
testcase_14 AC 14 ms
4,380 KB
testcase_15 AC 14 ms
4,376 KB
testcase_16 AC 41 ms
4,376 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 27 ms
4,380 KB
testcase_19 AC 36 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 14 ms
4,380 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 22 ms
4,380 KB
testcase_24 AC 20 ms
4,376 KB
testcase_25 AC 36 ms
4,376 KB
testcase_26 AC 22 ms
4,380 KB
testcase_27 AC 21 ms
4,376 KB
testcase_28 AC 22 ms
4,376 KB
testcase_29 AC 21 ms
4,380 KB
testcase_30 AC 21 ms
4,376 KB
testcase_31 AC 21 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

#define MOD 1000000007

long long extgcd(int a, int b, int& x, int& y) {
	int gcd_ = a;
	if (b) {
		gcd_ = extgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	else {
		x = 1; y = 0;
	}
	return gcd_;
}
//逆元を計算 O(log MOD)
int inv_mod(int a) {
	int x, y;
	extgcd(a, MOD, x, y);
	return (MOD + x % MOD) % MOD;
}

long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

int n;
int a[100000];


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	rep(i, n)cin >> a[i];
	long long ans = 1;

	long long s = a[0], sm = a[0];
	int e = 1;
	rep(i, n) {
		while (e < n && s * a[e] < 1000000000) {
			s *= a[e];
			sm *= s;
			sm %= MOD;
			e++;
		}
		ans *= sm;
		ans %= MOD;
		s /= a[i];
		sm = sm * pow_mod(inv_mod(a[i]), e - i) % MOD;
	}

	cout << ans << endl;


	
	return 0;
}
0