You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
555 B
25 lines
555 B
2 years ago
|
#include <bits/stdc++.h>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
//分解质因数
|
||
|
void divide(int x) {
|
||
|
for (int i = 2; i * i <= x; i++) {
|
||
|
int s = 0;
|
||
|
while (x % i == 0) x /= i, s++;
|
||
|
//输出多个因子乘积
|
||
|
for (int j = 1; j <= s; j++) {
|
||
|
cout << i;
|
||
|
if (j < s) cout << "*";//防止输出最后面的*号
|
||
|
}
|
||
|
}
|
||
|
//如果还没有除开,就是还需要写一个
|
||
|
if (x > 1) cout << '*' << x << endl;
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
int x;
|
||
|
cin >> x;
|
||
|
divide(x);
|
||
|
return 0;
|
||
|
}
|