杭电 HDU 1164 Eddy's research I

Eddy‘s research I

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 7117    Accepted Submission(s): 4268

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

Author

eddy

重点是素数判定

#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;
}
	

杭电 HDU 1164 Eddy's research I

时间: 2024-12-09 22:03:22

杭电 HDU 1164 Eddy's research I的相关文章

hdu 1164 Eddy&#39;s research I

1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<string> 5 #include<cmath> 6 #include<algorithm> 7 using namespace std; 8 #define MAX 65535 9 int prime[MAX+5]; 10 bool vis[MAX+5]; 11 int index=0; 1

HDU 1164 Eddy&#39;s research I【素数筛选法】

思路:将输入的这个数分成n个素数的相乘的结果,用一个数组存储起来.之后再输出就可以了 Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6633    Accepted Submission(s): 3971 Problem Description Eddy's interest is very ext

杭电 HDU 1163 Eddy&#39;s digital Roots

Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4904    Accepted Submission(s): 2743 Problem Description The digital root of a positive integer is found by summing the digi

杭电 HDU 1098 Ignatius&#39;s puzzle

Ignatius's puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7068    Accepted Submission(s): 4883 Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no

HDU 1165 Eddy&#39;s research II

Eddy's research II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3970    Accepted Submission(s): 1459 Problem Description As is known, Ackermann function plays an important role in the sphere

杭电 HDU 1038 Biker&#39;s Trip Odometer

Biker's Trip Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4745    Accepted Submission(s): 3144 Problem Description Most bicycle speedometers work by using a Hall Effect sensor faste

HDOJ 1164 Eddy&#39;s research I

[题意]:对一个数进行因式分解. [思路]:打表后一个一个除,最大数是65535,所以10000的质数范围苟用. [AC代码]: #include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <iomanip> using namespace std; #define MAX 10000 i

hdu 1165 Eddy&#39;s research II(数学题,递推)

// Eddy 继续 Problem Description As is known, Ackermann function plays an important role in the sphere of theoretical computer science. However, in the other hand, the dramatic fast increasing pace of the function caused the value of Ackermann function

HDU 1165 Eddy&#39;s research II (推公式)

Eddy's research II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3122    Accepted Submission(s): 1137 Problem Description As is known, Ackermann function plays an important role in the sphere