結果

問題 No.847 Divisors of Power
ユーザー claw88claw88
提出日時 2019-07-05 22:44:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,684 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 173,336 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 07:54:15
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑
using pi = pair<long, long>;
long N, K, M;
vector<pi> P;
int ans = 0;

void dfs(int i, long now)
{
	if (i == P.size() - 1)
	{
		for (int j = 0; j <= P[i].second; j++)
		{
			ans++;
			now *= P[i].first;
			if (now > M)break;
		}

		//cout << now << " " << ans << endl;
		return;
	}

	for (int j = 0; j <= P[i].second; j++)
	{
		dfs(i + 1, now);
		now *= P[i].first;
		if (now > M)break;
	}
}
void solve()
{
	
	cin >> N >> K >> M;
	long W = N;
	if (N == 1)
	{
		cout << 1 << endl;
		return;
	}

	map<long, long> G;
	for (long i = 2; i * i <= W; i++)
	{
		while (W % i == 0)
		{
			G[i]++;
			W /= i;
		}
	}
	if (W != 1)
	{
		G[W]++;
	}

	for (auto v : G)
	{
		int cnt = 0;
		long mul = v.first;
		long now = 1;
		while (true)
		{
			now *= mul;
			if (now > M)
			{
				break;
			}
			cnt++;
		}
		G[v.first] = min((long)cnt, v.second * K);
		P.emplace_back(pi(v.first, G[v.first]));
	}
	//for (auto v : P)
	//{
	//	cout << v.first << " " << v.second << endl;
	//}

	dfs(0, 1);
	cout << ans << endl;
	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}
0