結果

問題 No.1164 GCD Products hard
ユーザー msm1993msm1993
提出日時 2020-09-11 16:19:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 2,500 ms
コード長 848 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 48,984 KB
実行使用メモリ 18,272 KB
最終ジャッジ日時 2023-08-26 23:39:48
合計ジャッジ時間 6,378 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
17,464 KB
testcase_01 AC 198 ms
16,732 KB
testcase_02 AC 161 ms
16,736 KB
testcase_03 AC 104 ms
17,004 KB
testcase_04 AC 101 ms
17,068 KB
testcase_05 AC 175 ms
17,296 KB
testcase_06 AC 193 ms
16,784 KB
testcase_07 AC 193 ms
17,264 KB
testcase_08 AC 178 ms
17,516 KB
testcase_09 AC 156 ms
16,684 KB
testcase_10 AC 108 ms
16,836 KB
testcase_11 AC 167 ms
16,772 KB
testcase_12 AC 201 ms
17,720 KB
testcase_13 AC 151 ms
17,324 KB
testcase_14 AC 135 ms
17,324 KB
testcase_15 AC 190 ms
17,008 KB
testcase_16 AC 148 ms
16,732 KB
testcase_17 AC 179 ms
17,536 KB
testcase_18 AC 164 ms
17,792 KB
testcase_19 AC 108 ms
17,272 KB
testcase_20 AC 127 ms
16,816 KB
testcase_21 AC 213 ms
16,992 KB
testcase_22 AC 79 ms
18,272 KB
testcase_23 AC 170 ms
16,800 KB
testcase_24 AC 227 ms
16,768 KB
testcase_25 AC 78 ms
17,524 KB
testcase_26 AC 78 ms
17,532 KB
testcase_27 AC 80 ms
17,568 KB
testcase_28 AC 83 ms
18,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kMod = int(1E9 + 7), kN = int(1E7 + 10);

bool is_prime[kN];
vector<int> prime;

ll Pow(ll a, ll b, ll m) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

void pre() {
	for (int i = 2; i < kN; i++) is_prime[i] = true;
	for (int i = 2; i < kN; i++) {
		if (is_prime[i]) prime.PB(i);
		for (int j : prime) {
			if (i * j >= kN) break;
			is_prime[i * j] = false;
			if (i % j == 0) break;
		}
	}
	return ;
}

int main() {
	ll ans = 1, a, b, n, tmp;
	scanf("%lld%lld%lld", &a, &b, &n);
	pre();
	for (int i : prime) {
		tmp = i;
		while (tmp <= b) {
			ans = ans * Pow(i, Pow(b / tmp - (a - 1) / tmp, n, kMod - 1), kMod) % kMod;
			tmp *= i;
		}
	}
	printf("%lld\n", ans);
}
0