【hdu - 1164 Eddy's research I】
2012-07-08 21:17
260 查看
Eddy's research I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3554 Accepted Submission(s): 2182
[align=left]Problem Description[/align]
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 .
[align=left]Input[/align]
The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.
[align=left]Output[/align]
You have to print a line in the output for each entry with the answer to the previous question.
[align=left]Sample Input[/align]
11
9412
[align=left]Sample Output[/align]
11
2*2*13*181
[align=left]Author[/align]
eddy
[align=left]Recommend[/align]
JGShining
// Project name : 1164 ( Eddy's research I ) // File name : main.cpp // Author : Izumu // Date & Time : Sun Jul 8 21:07:17 2012 #include <iostream> #include <stdio.h> #include <cmath> using namespace std; int main() { int num; while (cin >> num) { int* prime; prime =new int[1000]; int top = -1; int current_prime = 2; int CGetNextPrime(int); while (num != 1) { if (num % current_prime == 0) { top++; prime[top] = current_prime; num /= current_prime; } else { current_prime = CGetNextPrime(current_prime); } } // output for (int i = 0; i < top; i++) { cout << prime[i] << "*"; } cout << prime[top] << endl; } return 0; } /*********************************************************************/ bool CIsPrime(int k) { int stop = sqrt(k); bool yes = true; for (int i = 2; yes && i <= stop; i++) { if (k % i == 0) { yes = false; } } return yes; } /*********************************************************************/ int CGetNextPrime(int num) { num++; while (!CIsPrime(num)) { num++; } return num; } // end // ism
相关文章推荐
- HDU 1164 Eddy's research I
- Hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I 素数筛选法
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I (数论)
- HDU 1164 Eddy's research I
- 整数分解(3种算法比较):hdu 1164 Eddy's research I+poj 1811 Prime Test
- hdu 1164 Eddy's research I
- HDU - 1165 - Eddy's research II
- hdu1164-Eddy's research I
- hdu 1165 Eddy's research II (DP)
- HDOJ 1164 Eddy's research I
- HDU1164 Eddy's research I
- HDOJ HDU 1164 Eddy's research I ACM 1164 IN HDU
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU 1165 Eddy's research II (找规律)
- HDU 1164 Eddy's research I