Files
python/TangDou/Test/TD.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

31 lines
678 B
C++

#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
cin >> n;
bool first = true;
for (long long p = 2;p*p<=n;p++){
if (n % p != 0) continue;
int cnt = 0;
while (n % p == 0){
n /= p;
cnt++;
}
if (first){
first = false;
cout << p;
}else{
cout << " * " << p;
}
if (cnt > 1) cout << " ^ " << cnt;
}
if (n != 1){
if (first){
first = false;
cout << n;
}else{
cout << " * " << n;
}
}
return 0;
}