HDU 1164
因为规模小,使用试除法即可
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const int Maxn=100;
int prime[Maxn];
int main(){
int n,m;
while(scanf("%d",&n)!=EOF){
int l=(int)sqrt(n*1.0);
int tot=0; m=n;
for(int i=2;i<=l;i++){
if(m%i==0){
// cout<<i<<endl;
while(m%i==0){
prime[tot++]=i;
m/=i;
}
}
}
if(m>1)
prime[tot++]=m;
printf("%d",prime[0]);
for(int i=1;i<tot;i++)
printf("*%d",prime[i]);
printf("\n");
}
return 0;
}

浙公网安备 33010602011771号