题解
2025-11-09 12:38:42
发布于:北京
12阅读
0回复
0点赞
**#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
// 计算阶乘
ll factorial(int n) {
ll res = 1;
for (int i = 2; i <= n; i++) {
res *= i;
}
return res;
}
int main() {
int x;
while (cin >> x) {
// 质因数分解
map<int, int> factors;
int temp = x;
for (int i = 2; i * i <= temp; i++) {
while (temp % i == 0) {
factors[i]++;
temp /= i;
}
}
if (temp > 1) {
factors[temp]++;
}
// 计算总指数和
int total_exp = 0;
for (auto &factor : factors) {
total_exp += factor.second;
}
// 计算多重排列数
ll count = factorial(total_exp);
for (auto &factor : factors) {
count /= factorial(factor.second);
}
cout << total_exp << " " << count << endl;
}
return 0;
}**
这里空空如也







有帮助,赞一个