题目描述
C++代码
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
cout << n << "=";
if (n == 1) {
cout << n;
}
bool vis = true;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
int s = 0;
while (n % i == 0) {
s++;
n /= i;
}
if (vis) vis = false;
else cout << "*";
cout << i;
if (s > 1) {
cout << "^" << s;
}
}
}
if (n > 1) {
if (vis) cout << n;
else cout << "*" << n;
}
return 0;
}