結果

問題 No.1164 GCD Products hard
ユーザー tkmst201tkmst201
提出日時 2021-01-23 09:49:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,220 bytes
コンパイル時間 1,801 ms
コンパイル使用メモリ 200,868 KB
実行使用メモリ 38,828 KB
最終ジャッジ日時 2023-08-28 18:31:27
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

namespace tk {
template<typename T>
T mod_pow(T x, T n, const T & mod) {
	assert(mod > 0);
	assert(n >= 0);
	x = (x % mod + mod) % mod;
	T res = 1 % mod;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
} // namespace tk


int main() {
	int A, B, N;
	cin >> A >> B >> N;
	ll ans = 1;
	vector<int> dp(B + 1);
	for (int i = B; i >= 1; --i) {
		dp[i] = tk::mod_pow<ll>(B / i - (A - 1) / i, N, MOD - 1);
		for (int j = i + i; j <= B; j += i) dp[i] = (dp[i] - dp[j] + MOD - 1) % (MOD - 1);
		ans = ans * tk::mod_pow<ll>(i, dp[i], MOD) % MOD;
	}
	cout << ans << endl;
}
0