結果

問題 No.847 Divisors of Power
ユーザー ahe100ahe100
提出日時 2019-07-05 22:18:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,355 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 169,888 KB
実行使用メモリ 6,256 KB
最終ジャッジ日時 2024-04-16 07:33:26
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
924844033 1000000000 924844033
10 10 10
264577 10 10000000000
1 1 3
5040 1000000000 1000000000
*/

void prime_list(ll n,vector<ll>& p){
	ll visited[300010]={};
	reg(i,2,n){
		if(visited[i]==0){
			p.push_back(i);
			reg(j,2,n){
				if(j*i>n)break;
				visited[i*j]=1;
			}
		}
	}
}
void factoring(ll n,vector<pair<ll,ll>>& v,vector<ll>& p){
	rep(i,p.size()){
		while(n%p[i]==0){
			n/=p[i];
			if(v.size()==0 || v.back().first!=p[i])v.push_back({p[i],0});
			v.back().second++;
		}
	}
	if(n>1)v.push_back({n,1});
}

ll n,k,m;
vector<ll> prime;
vector<pair<ll,ll>> fact;

ll f(ll x,ll t){
	if(x>m)return 0;
	if(t==fact.size()){
		// cerr<<"solve :"<<x<<endl;
		return 1;
	}
	ll tmp=1,ans=0;
	for(ll i=0;i<=fact[t].second;i++){
		if(x*tmp>m)break;
		ans+=f(x*tmp,t+1);
		tmp*=fact[t].first;
	}
	return ans;
}

void init(){
	cin>>n>>k>>m;
	prime_list(200000,prime);
	factoring(n,fact,prime);
	rep(i,fact.size())fact[i].second*=k;
	// rep(i,fact.size())cerr<<fact[i].first<<","<<fact[i].second<<endl;
}

int main(void){
	init();
	cout<<f(1,0)<<endl;
	return 0;
}
0