AcWing 1295. X的因子链
原题链接
中等
作者:
Ard残梦
,
2024-03-25 17:42:23
,
所有人可见
,
阅读 4
#include <bits/stdc++.h>
#define int long long
#define fr first
#define se second
using namespace std;
int fun(int x)
{
if(x == 1) return 1;
return x * fun(x - 1);
}
signed main()
{
int x;
map<int, int> mp;
while(cin >> x)
{
mp.clear();
for(int i = 2; i * i <= x ; i++)
{
while(x % i == 0)
{
x /= i;
mp[i] ++;
}
}
if(x > 1) mp[x] ++;
int res = 0, cnt = 1;
for(auto aa : mp)
{
res += aa.se;
cnt *= fun(aa.se);
}
cout << res << " " << fun(res) / cnt << endl;
}
}