#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL f[30];
int c[1200000];
int main() {
int x;
f[0] = 1;
for (int i = 1; i <= 20; ++i)
f[i] = i * f[i - 1];
while (~scanf("%d", &x)) {
int tot = 0;
LL ans;
c[0] = 0;
for (int i = 2; i * i <= x; ++i) {
if (x % i == 0) {
c[++c[0]] = 0;
while (x % i == 0) {
x /= i;
c[c[0]]++;
}
tot += c[c[0]];
}
}
if (x > 1)
c[++c[0]] = 1, tot++;
ans = f[tot];
for (int i = 1; i <= c[0]; ++i)
ans /= f[c[i]];
printf("%d %lld\n", tot, ans);
}
return 0;
}
一本通1628:X-factor Chain
这篇文章描述了一个C++程序,用于计算输入整数x的质因数分解,并统计各个质因子的出现次数。程序通过循环和除法操作实现质因数计算,最后输出质因子的总数和相应的阶乘值。
摘要由CSDN通过智能技术生成