Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
529 B
C++

#include <bits/stdc++.h>
using namespace std;
//分解质因数
void divide(int x) {
for (int i = 2; i * i <= x; i++) {
int cnt = 0;
while (x % i == 0) x /= i, cnt++;
//输出多个因子乘积
for (int j = 1; j <= cnt; j++) {
cout << i;
if (j < cnt) cout << "*";//防止输出最后面的*号
}
}
//如果还没有除开,就是还需要写一个
if (x > 1) cout << '*' << x << endl;
}
int main() {
int x;
cin >> x;
divide(x);
return 0;
}