count表示次方,如果次方=1就不用印"^"了
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i = 2; i <= n; i ++){
int count = 0;
while(n % i == 0){
n /= i;
count++;
}
if(count >= 2){
cout<<i<<"^"<<count;
if(n !=1){
cout<<" * ";
}
}else if(count == 1){
cout<<i;
if(n !=1){
cout<<" * ";
}
}else{
}
}
return 0;
}