結果

問題 No.847 Divisors of Power
ユーザー okok
提出日時 2019-07-05 22:32:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 91,508 KB
実行使用メモリ 9,808 KB
最終ジャッジ日時 2024-04-16 07:48:59
合計ジャッジ時間 1,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 1100000000

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K, M;
	int m;
	// static bool x[MAX];
	vector<pair<int,int>> t;
	vector<int> vec;
	set<int> se;
	
	// x[1] = true;
	
	se.insert(1);
	
	cin>>N>>K>>M;
	
	m = N;
	
	for(int i = 2; i*i <= m; i++){
		
		while(m%i == 0){
			if(t.size() == 0 || t.back().first != i) t.push_back(make_pair(i,1));
			else t.back().second++;
			m /= i;
		}
	}
	
	if(m != 1) t.push_back(make_pair(m,1));
	
	sort(t.begin(), t.end());
	
	for(int i = 0; i < t.size(); i++){
		t[i].second *= K;
		// cout<<t[i].first<<" "<<t[i].second<<endl;
		vec.clear();
		for(int l : se){
			for(int j = l*t[i].first, k = 0; k < t[i].second && j <= M; j *= t[i].first, k++){
				// x[j] = true;
				vec.push_back(j);
				// cout<<l<<" "<<j<<"k = "<<k<<endl;
			}
		}
		for(int l : vec){
			se.insert(l);
		}
	}
	
	// for(int l : se){
		// cout<<l<<endl;
	// }
	cout<<se.size()<<endl;
	
	return 0;
}
0