結果

問題 No.847 Divisors of Power
ユーザー snrnsidysnrnsidy
提出日時 2021-12-24 04:54:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 3,064 ms
コンパイル使用メモリ 214,788 KB
実行使用メモリ 10,356 KB
最終ジャッジ日時 2023-10-19 04:54:25
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <int> prime;
bool isprime[31625];

void eratos(void)
{
	memset(isprime,true,sizeof(isprime));

	for(int i=2;i<31625;i++)
	{
		if(isprime[i])
		{
			prime.push_back(i);
			for(int j=2*i;j<31625;j+=i)
			{
				isprime[j]=false;
			}
		}
	}
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int n,k,m;
	set <long long int> S;
	vector <pair<long long int,long long int>> v;
	cin >> n >> k >> m;

	eratos();

	long long int x = n;
	for(int j=0;j<prime.size();j++)
	{
		if(x==1 || x<prime[j]*prime[j])
		{
			break;
		}
		long long int cnt = 0;
		while(1)
		{
			if(x%prime[j]!=0)
			{
				break;
			}
			cnt++;
			x/=prime[j];	
		}
		v.push_back(make_pair(prime[j],cnt*k));
	}

	if(x>1)
	{
		v.push_back(make_pair(x,k));
	}

	S.insert(1);
	for(int i=0;i<v.size();i++)
	{
		long long int p = v[i].first;
		long long int N = v[i].second;
		vector <long long int> temp;
		for(auto it : S)
		{
			long long int val = it;
			for(long long int j=0;j<N;j++)
			{
				val*=p;
				if(val > m) break;
				temp.push_back(val);
			}
		}
		for(auto it : temp) S.insert(it);
	}

	cout << S.size() << '\n';
	
	return 0;
}
0