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