hdu 1164 Eddy's research I (数论)
来源:互联网 发布:mysql优化查询速度 编辑:程序博客网 时间:2024/06/12 21:45
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 2 Accepted Submission(s) : 2
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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
119412
Sample Output
112*2*13*181
Author
#include<iostream>#include<cstring>#define N 68535#define M 300using namespace std;bool isnop[N];//判断素数int prime[N];//按顺序存素数int ans;void isprime(){ ans=-1; memset(isnop,0,sizeof(isnop)); isnop[0]=isnop[1]=1; for(int i=2;i<M;i++) { if(!isnop[i]) { prime[++ans]=i; for(int j=i+i;j<N;j+=i) isnop[j]=1; } } for(int i=M-1;i<N;i++) if(!isnop[i]) prime[++ans]=i;}int main(){ int m,i; isprime(); while(cin>>m) { i=0; while(1) { if(m%prime[i]==0&&m) { m/=prime[i]; if(m!=1) cout<<prime[i]<<"*"; else { cout<<prime[i]<<endl; break; } } else ++i; } }}
- HDU 1164 Eddy's research I 数论
- hdu 1164 Eddy's research I (数论)
- HDU 1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I
- Hdu 1164-Eddy's research I
- hdu(1164)Eddy's research I
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I
- hdu-1164-Eddy's research I
- hdu-oj 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU 1164 Eddy's research I.doc
- Apache Common Configuration--超方便的配置文件读取解析
- asyncTask了解简记
- n个骰子的点数和
- android 开发环境配置
- java Class object
- hdu 1164 Eddy's research I (数论)
- hibernate openSession和getCurrentSession
- Linux音频编程指南
- 对时间管理妙招的评价
- C#正则表达式快速入门
- Hibernate 简单的annotation
- 修改镜像文件大小
- Linux 下采用开源MONO第一个C#程序
- Android socket和Tomcat等网络连接不上问题解决方案