考虑值小于2的特殊情况
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
int main(){
int n;
cin >> n;
if(n<=1){
printf("%d=%d", n, n);
return 0;
}
map<int,int> factors;
int num = n, d = 2;
while(num != 1){
if(num%d) ++d;
else{
if(factors.find(d) == factors.end()) factors[d] = 0;
++factors[d];
num /= d;
}
}
printf("%d=", n);
bool first = true;
for(auto& item : factors){
if(first) first = false;
else printf("*");
if(item.second == 1) printf("%d", item.first);
else printf("%d^%d", item.first, item.second);
}
return 0;
}