結果

問題 No.847 Divisors of Power
ユーザー lightninglightning
提出日時 2019-07-05 22:31:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 1,943 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 207,748 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-16 07:48:22
合計ジャッジ時間 3,691 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 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,944 KB
testcase_07 AC 2 ms
6,940 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,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 180 ms
8,576 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 41 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,948 KB
testcase_24 AC 222 ms
9,728 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

ll n, k, m; 
set<ll> s;

void dfs(vector<int> a,vector<ll>& soinsu,vector<vector<ll>>& dp, ll pro=1) {
	
	REP(i, a.size()) {
		if (a[i] < dp[i].size()) {
			vector<int> next(a.size());
			REP(j, a.size()) {
				next[j] = a[j];
			}
			next[i]++;
			ll temp = pro * soinsu[i];
			if (temp <= m){
				auto itr = s.find(temp);
				if (itr == s.end()) {
					s.insert(temp);
					dfs(next, soinsu, dp, pro* soinsu[i]);
				}
				
			}
			
		}
	}
}

int main() {
	
	cin >> n >> k >> m;
	vector<ll> soinsu;
	vector<ll> shisu;
	for (int i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			soinsu.push_back(i);
			shisu.push_back(1);
			n /= i;
		}
		while (n % i == 0) {
			n /= i;
			shisu.back()++;
		}
	}
	if (n != 1) {
		soinsu.push_back(n);
		shisu.push_back(1);
	}
	int l = shisu.size();
	REP(i,l) {
		shisu[i] *= k;
	}
	vector<vector<ll>> dp(l);
	REP(i, l) {
		ll  temp = 1;
		for (int j = 0; j <= shisu[i] && temp <= m; ++j) {
			dp[i].push_back(temp);
			temp *= soinsu[i];
		}
	}
	vector<int> a(l, 1);
	s.insert(1);
	dfs(a,soinsu,dp);
	put(s.size());
	return 0;
}


0