結果

問題 No.847 Divisors of Power
ユーザー zunda1stzunda1st
提出日時 2019-03-27 23:36:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,718 bytes
コンパイル時間 1,122 ms
コンパイル使用メモリ 98,072 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 06:59:49
合計ジャッジ時間 2,273 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<math.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

vector<pair<ll,ll>> primeFactorDecomp(ll n){
	  vector<pair<ll,ll>> ret;
	  ll m=n;
	  for(ll i=2;i*i<=m;i++){
			if(n%i!=0) continue;
			ll cnt=0;
			while(n%i==0){
				  cnt++;
				  n/=i;
			}
			ret.push_back({i,cnt});
	  }
	  if(n>1){
			ret.push_back({n,1});
	  }
	  return ret;
}
ll hukugen(vector<P>& p){
	ll ret=1;
	for(auto q:p){
		for(int i=1;i<=q.second;i++){
			ret*=q.first;
		}
	}
	return ret;
}

int a[15];
ll expone[15];
int N;
bool nexta(int i){
	if(a[i]>=expone[i]){
		a[i]=0;
		nexta(i+1);
	}
	else{
		a[i]++;
		return true;
	}
	return true;
}

int main(){
	ll n,k,m;
	cin>>n>>k>>m;
	vector<P> bunkai=primeFactorDecomp(n);
	N=bunkai.size();
	for(int i=N;i<=N+1;i++){
		bunkai.push_back(make_pair(1e9+7, 2));
	}
	rep0(i,N+1) expone[i]= min(32ll, bunkai[i].second*k);
	rep0(i,N+1) a[i]=0;
	ll pos=1;
	ll ans=0;
	do{
		if(a[N]>0) break;
		/*rep0(i,N){
			cout<<a[i]<<" ";
		}
		cout<<endl;*/
		vector<P> posdec(N);
		rep0(i,N) posdec[i]={bunkai[i].first,a[i]};
		pos=hukugen(posdec);
		if(pos<=m&&pos>=0){
			ans++;
		}
		else{
			int i=0;
			while(a[i]==0){
				a[i]=expone[i];
				i++;
			}
			a[i]++;
		}
	}while(nexta(0));
	cout<<ans<<endl;

	return 0;
}
0