HDU 1164  Eddy's research I

来源:互联网 发布:京东网络促销活动对象 编辑:程序博客网 时间:2024/06/07 07:08

Eddy's research I

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5098    Accepted Submission(s): 3056


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
eddy
 

Recommend
JGShining
将一个数分解成一个素数相乘的形式
#include<iostream>#include<cstring>using namespace std;int main(){    int n;    int a[65536];    int b[100];    int i,j,k;    memset(a,0,sizeof(a));    a[0]=a[1]=1;    for(i=2;i<65536;i++)    {       if(!a[i])       for(j=i*2;j<65536;j+=i)         a[j]=1;    }    while(cin>>n)    {         for(i=2,k=0;i<65536&&n;)            {                if(!a[i])                {                    if(n%i==0)                    {                        b[k++]=i;                        n/=i;                        i=2;                    }                    else i++;                }                else i++;            }        for(i=0;i<k;i++)        if(i==k-1)        cout<<b[i]<<endl;        else        cout<<b[i]<<"*";    }    return  0;}


原创粉丝点击