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 }
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 }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步