Eddy ' s-I

Source: Internet
Author: User

Eddy ' s-ITime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 7601 Accepted Submission (s): 4618


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 Eddy H As-to-ask intelligent you-to-help him, he asks-to-write a program which can does the number to divided into the multiply 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 this method is good. From small to large ~ Reference blog: http://blog.csdn.net/lishuhuakai/article/details/8184207
#include <iostream> #include <stdio.h> #include <math.h> #include <string.h>using namespace std    ; bool A[65535];void IsPrime () {memset (a,true,sizeof (a));    int i,j;    A[0]=a[1]=false;                For (I=2;I&LT;SQRT (65535), i++) {if (A[i]) {for (j=i*i;j<65535;j+=i) {            A[j]=false;    }}}}int Main () {int x,flag,i,max;    IsPrime ();        while (scanf ("%d", &x)!=eof) {max=x;        flag=1;                    for (i=2;i<=max;i++) {while (A[i] && x%i==0) {if (flag)                       {cout<<i;                    flag=0;                    } else {cout<< "*" <<i;                } x=x/i;                 if (x==1) {cout<<endl;break; }}}} return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Eddy ' s-I

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.