結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
silopy
|
| 提出日時 | 2019-07-06 00:01:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 768 bytes |
| コンパイル時間 | 771 ms |
| コンパイル使用メモリ | 90,004 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-06 23:25:29 |
| 合計ジャッジ時間 | 1,590 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
using lint=int64_t;
template<typename T>
void pfact(map<T,T> &m,T n)
{
T x=n;
for(T i=2;i*i<=n;i++)
{
while(x%i==0)
{
m[i]++;
x/=i;
}
}
if(x!=1)m[x]++;
return;
}
lint N,K,M;
map<lint,lint> pfN;
vector<pair<lint,lint>> facts;
lint depth;
lint ans=0;
void dfs(lint d,lint cur)
{
if(d==depth)
{
ans++;
return;
}
for(lint i=0;i<=facts[d].second*K;i++)
{
lint nxt=cur*pow(facts[d].first,i);
if(nxt>M)break;
dfs(d+1,nxt);
}
return;
}
int main()
{
cin >> N >> K >> M;
pfact<lint>(pfN,N);
for(auto& i:pfN)
facts.push_back(make_pair(i.first,i.second));
depth=facts.size();
dfs(0,1);
cout << ans << endl;
return 0;
}
silopy