結果

問題 No.847 Divisors of Power
ユーザー sprng_wlsprng_wl
提出日時 2019-07-06 02:12:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 166,536 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 08:19:22
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 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,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 6 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 1 ms
6,944 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>
#define Int int64_t

using namespace std;
using P = pair<Int, Int>;

template <typename T>
vector<pair<T, T>> prime_factorize(T n) {
	vector<pair<T, T>> ret;

	for (T p = 2; p * p <= n; p++) {
		if (n % p != 0) { continue; }

		T num = 0;
		while (n % p == 0) {
			num++;
			n /= p;
		}
		ret.push_back(P(p, num));
	}
	if (n != 1) ret.push_back(P(n, 1));

	return ret;
}

int main() {
	Int N, K, M;
	cin >> N >> K >> M;
	vector<P> v = prime_factorize(N);

	vector<Int> res;
	res.emplace_back(1);
	vector<Int> tmp;
	for (int i = 0; i < v.size(); ++i) {
		Int f = v[i].first, s = v[i].second;
		for (auto val : res) {
			tmp.emplace_back(val);
			Int t = f;
			for (int j = 0; j < s * K; ++j) {
				if (val * t <= M) {
					tmp.emplace_back(val * t);
					t *= f;
				} else {
					break;
				}
			}
		}
		res = tmp;
		tmp.clear();
	}
	cout << res.size() << endl;

	return 0;
}
0