题解:B4070 [GESP202412 五级] 奇妙数字
FJ_EYoungOneC · · 题解
解题思路
数字
那么我们可以对
假设数字
那么我们需要计算的就是
我们可以使用二分 long long 范围以内,质因子最多个数的即为
AC_Code
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL x;
int calc(int x)
{
int res = 0, k = 1;
while (x >= k)
{
res ++;
x -= k ++;
}
return res;
}
int main()
{
cin >> x;
LL res = 0;
for (int i = 2; i <= x / i; ++ i )
{
int cnt = 0;
while (x % i == 0)
x /= i, cnt ++;
if (cnt)
res += calc(cnt);
}
if (x > 1)
res ++;
cout << res << endl;
return 0;
}