結果

問題 No.847 Divisors of Power
ユーザー ldsybldsyb
提出日時 2019-07-05 23:35:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 174,980 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-16 08:13:13
合計ジャッジ時間 5,715 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
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 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n, k, m;
	cin >> n >> k >> m;

	if (n == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	vector<int64_t> pf;

	for (int64_t i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			pf.emplace_back(i);
			n /= i;
		}
	}
	if (n != 1)
	{
		pf.emplace_back(n);
	}

	sort(pf.begin(), pf.end());

	vector<pair<int64_t, int64_t>> v;
	v.push_back({pf[0], 1});
	for (int64_t i = 1; i < pf.size(); i++)
	{
		if (v.rbegin()->first == pf[i])
		{
			v.rbegin()->second++;
		}
		else
		{
			v.push_back({pf[i], 1});
		}
	}
	for (auto &p : v)
	{
		p.second *= k;
	}

	auto f = [&](auto &g, int64_t now = 1, int64_t i = 0) {
		if (m < now)
		{
			return int64_t(0);
		}
		if (i == v.size())
		{
			return int64_t(now <= m);
		}

		int64_t r = 0;

		for (int64_t j = 0, l = 1; j <= v[i].second; j++, l *= v[i].first)
		{
			r += g(g, now * l, i + 1);
		}

		return r;
	};

	cout << f(f) << endl;

	return 0;
}
0