hdu 1164 Eddy's research I
2013-08-31 17:03
411 查看
Eddy's research I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5201 Accepted Submission(s): 3127
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<iostream>
#include <cstdio>
#include<cstring>
#include<algorithm>
#include <cmath>
using namespace std;
int main()
{
int x,i,j,a[10000],b[1002];
memset(a,0,sizeof(a));
for(i=2;i<10000;i++)
for(j=i*2;j<10000;j+=i)
a[j]=1;
while(~scanf("%d",&x))
{
int t=0,s=x;
for(i=2;i<=1000&&x!=1;i++)
{
if(a[i]==0&&x%i==0)
while(x%i==0)
{
b[t++]=i;
x/=i;
}
}
if(x==1)
{
for(i=0;i<t-1;i++)
printf("%d*",b[i]);
printf("%d\n",b[t-1]);
}
else
{
for(i=0;i<=t-1;i++)
printf("%d*",b[i]);
printf("%d\n",x);
}
}
return 0;
}
相关文章推荐
- hdu 1164 Eddy's research I
- Hdu 1164-Eddy's research I
- HDOJ HDU 1164 Eddy's research I ACM 1164 IN HDU
- HDU's ACM 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
- 整数分解(3种算法比较):hdu 1164 Eddy's research I+poj 1811 Prime Test
- hdu1164-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
- HDU1164_Eddy's research I【Miller Rabin素数测试】【Pollar Rho整数分解】
- HDU1164 Eddy's research I
- HDU 1164 Eddy's research I
- HDU 1164 Eddy's research I
- HDU 1164 Eddy's research I