31 lines
678 B
C++
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;
|
|
} |