本文主要是介绍hdu1164,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Eddy’s research I
*Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14666 Accepted Submission(s): 8935
*
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
Recommend
JGShining | We have carefully selected several similar problems for you: 1215 1211 1061 1299 1163
代码
#include <bits/stdc++.h>
using namespace std;int i;int main()
{int n;while(scanf("%d", &n)==1 ){bool flag = false;for(i = 2; i * i<= n; i ++){int cnt = 0;while(n % i== 0){cnt ++;n /= i;}if(cnt == 0){printf("");continue;}if(flag){putchar('*');}printf("%d",i);for(int i = 2; i <=cnt; i ++){printf("*%d", ::i);}flag = true;}if(n>1 ){if(flag) putchar('*');printf("%d", n);}printf("\n");}return 0;
}
这篇关于hdu1164的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!