Eddy's research I
2015-08-13 15:42
381 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1164
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7641 Accepted Submission(s): 4645
Problem Description
Eddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can't write program, so Eddy has to ask intelligent you to help him, he asks you to write
a program which can do the number to divided into the multiply of prime number factor .
Input
The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.
Output
You have to print a line in the output for each entry with the answer to the previous question.
Sample Input
Sample Output
打一个素数表,然后跑一遍素数表就可以了
Eddy's research I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7641 Accepted Submission(s): 4645
Problem Description
Eddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can't write program, so Eddy has to ask intelligent you to help him, he asks you to write
a program which can do the number to divided into the multiply of prime number factor .
Input
The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.
Output
You have to print a line in the output for each entry with the answer to the previous question.
Sample Input
11 9412
Sample Output
11 2*2*13*181
打一个素数表,然后跑一遍素数表就可以了
#include <cstdio> int prim[7000]; int main() { int j=1,k; prim[0]=2; for(int i=3;i<=65535;i+=2){ for(k=0;k<j;k++){ if(i%prim[k]==0)break; } if(k==j)prim[j++]=i; } int n,ans[1000]; while(scanf("%d",&n)!=EOF){ int m=0,i=0; while(n!=prim[m]){ if(n%prim[m]==0){ ans[i++]=prim[m]; n/=prim[m]; continue; } else m++; } ans[i++]=prim[m]; printf("%d",ans[0]); for(m=1;m<i;m++) printf("*%d",ans[m]); printf("\n"); } return 0; }
相关文章推荐
- EmguCV学习——简单使用
- bzoj2875
- SPI协议及其工作原理浅析
- 1.excle学习之一:工作环境设置
- C/C++获取当前系统时间
- iOS开发 汉字转拼音
- BitmapFactory.Options避免 内存溢出 OutOfMemoryError的优化方法
- 155 Min Stack
- hdu 3068 最长回文(manacher入门)
- MongoDB 自动分片 auto sharding
- 多进程监控自动关机工具升级远程关闭多台server——C# works with PowerShell
- 微软公布世界各国的Win10必备应用名单
- Linux shell中单引号 双引号 反引号 反斜杠的区别
- ADF实现表格分页效果
- Shell脚本编程-脚本格式
- Linux设备驱动核心理论(三)
- hdu3038,3047(带权并查集)
- Gold Balanced Lineup(POJ--3274
- Hnoi2010弹飞绵羊题解LCT
- js中typeof的用法汇总