hdoj1164

 

Eddy's research I

 1 #include<iostream>
 2 #include<string.h>
 3 #include<stdio.h>
 4 using namespace std;
 5 int prime[10000],cnt,n;
 6 bool primtmp[65538];
 7 int main(){
 8     cnt=0;
 9     memset(primtmp,-1,sizeof(primtmp));
10      for(int i=2;i<=65535;++i){//求素数
11         if(primtmp[i]){
12             prime[cnt++]=i;
13             int p=2*i;
14             while(p<=65535){
15                 primtmp[p]=0;
16                 p+=i;
17             }
18         }
19     }
20       while(scanf("%d",&n)!=EOF){
21     int pos=0;
22     while(n>1){
23     while(n%prime[pos]==0){
24         printf("%d",prime[pos]);
25         n/=prime[pos];
26         if(n>1)
27             printf("*");
28        }
29         pos++;
30      }
31     printf("\n");
32     }
33 }


posted @ 2010-05-08 17:33  open source  阅读(144)  评论(0编辑  收藏  举报