結果

問題 No.847 Divisors of Power
ユーザー tkmst201tkmst201
提出日時 2021-01-21 11:15:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,305 bytes
コンパイル時間 2,837 ms
コンパイル使用メモリ 205,852 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 22:38:55
合計ジャッジ時間 4,529 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
//---------------------------------//

std::vector<std::pair<ll, ll>> prime_factorization(ll n) {
	std::vector<std::pair<ll, ll>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) res.emplace_back(i, 1), n /= i;
		while (n % i == 0) ++res.back().second, n /= i;
	}
	if (n > 1) res.emplace_back(n, 1);
	return res;
}

int main() {
	int N, K, M;
	cin >> N >> K >> M;
	auto pf = prime_factorization(N);
	for (auto & [_, c] : pf) c *= K;
	
	auto dfs = [&](auto self, int i, int cur) -> int {
		if (i == pf.size()) return 1;
		int res = self(self, i + 1, cur);
		ll n = cur;
		
		REP(j, pf[i].second) {
			n *= pf[i].first;
			if (n >= M) break;
			res += self(self, i + 1, n);
		}
		return res;
	};
	cout << dfs(dfs, 0, 1) << endl;
}
0