Hangzhou Electric HDU 1164 Eddy ' s

Source: Internet
Author: User

Eddy ' s-I Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 7117 Accepted Submission (s): 4268


Problem Descriptioneddy ' s interest is very extensive, recently he's interested in prime number. Eddy Discover the all number owned can is divided into the multiply of prime number, but he can ' t write program, so EDD Y have to ask intelligent him, he asks you to write a program which can do the number to divided into the multi Ply of prime number factor.


Inputthe input would contain a number 1 < x<= 65535 per line representing the number of elements of the set.

Outputyou has 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

Authoreddy emphasis is on prime number determination
#include <iostream> #include <algorithm>using namespace Std;int prime[65536]={0};    int main () {for (int i=2;i<= (65535/2); i++) {int q;for (q=i+i;q<=65535;q+=i) prime[q]=1;   } int Ls[10000];int n;int Gq[100];while (cin>>n) {int t=0;for (int j=2;j<=65535;j++) {if (!prime[j]&&! ( N%j)) {ls[t++]=j;    N/=j;if (n==1) break; if (n<=j) j=1;} Sort (ls,ls+t); for (int k=0;k<t-1;k++) cout<<ls[k]<< "*"; cout<<ls[t-1]<<endl;} return 0;}

Hangzhou Electric HDU 1164 Eddy ' s

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.