- duanjiajun's blog
分解质因数 比赛用
- 2023-10-15 13:42:06 @
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int nn = sqrt(n);
int first = true;
cout << n << "=";
for (int i = 2; i <= nn; i++) {
while (n % i == 0) {
if (first) {
cout << i;
first = false;
} else {
cout << "*" << i;
}
n = n / i;
}
}
return 0;
}