重点在这张
![]()
补充知识(翻得《组合数学》PPT)
![]()
// 利用算术基本定理,找到N的质因子以及质因子个数
#include <iostream>
#include <algorithm>
using namespace std;
long long get_mul(long long x)
{
if (x == 0 || x == 1) return 1;
return x * get_mul(x - 1);
}
int main()
{
int x;
while (cin >> x)
{
unordered_map<int, long long> primes;
for (int i = 2; i <= x / i; i ++)
{
if (x % i == 0)
{
while (x % i == 0)
{
primes[i] ++;
x /= i;
}
}
}
if (x > 1) primes[x] ++;
long long max_len = 0;
for (auto elem : primes)
{
// cout << elem.first << ' ' << elem.second << endl;
auto cnt = elem.second;
max_len += cnt;
}
long long res = 1;
for (auto elem : primes)
{
auto cnt = elem.second;
res *= get_mul(cnt);
}
cout << max_len << ' ' << get_mul(max_len) / res << endl;
}
return 0;
}