結果

問題 No.1158 GCD Products easy
ユーザー ianCKianCK
提出日時 2020-08-12 05:44:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 38,016 KB
実行使用メモリ 18,672 KB
最終ジャッジ日時 2024-04-17 20:53:36
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
17,140 KB
testcase_01 AC 70 ms
17,012 KB
testcase_02 AC 71 ms
16,876 KB
testcase_03 AC 71 ms
17,648 KB
testcase_04 AC 71 ms
17,776 KB
testcase_05 AC 70 ms
17,132 KB
testcase_06 AC 77 ms
17,904 KB
testcase_07 AC 74 ms
17,392 KB
testcase_08 AC 71 ms
16,752 KB
testcase_09 AC 71 ms
17,136 KB
testcase_10 AC 73 ms
16,884 KB
testcase_11 AC 70 ms
16,624 KB
testcase_12 AC 70 ms
16,628 KB
testcase_13 AC 71 ms
16,628 KB
testcase_14 AC 71 ms
16,752 KB
testcase_15 AC 72 ms
17,008 KB
testcase_16 AC 71 ms
16,624 KB
testcase_17 AC 70 ms
17,136 KB
testcase_18 AC 72 ms
17,008 KB
testcase_19 AC 73 ms
16,880 KB
testcase_20 AC 72 ms
18,672 KB
testcase_21 AC 72 ms
16,748 KB
testcase_22 AC 72 ms
17,524 KB
testcase_23 AC 70 ms
17,388 KB
testcase_24 AC 69 ms
16,752 KB
testcase_25 AC 72 ms
16,628 KB
testcase_26 AC 68 ms
17,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%lld%lld%lld", &a, &b, &n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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