作业帮 > 综合 > 作业

Prime Factor

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/16 07:11:02
Prime Factor
Description
Give you a positive integer,please split it to some prime numbers,and you can got it through sample input and sample output.
Input
Input file contains multiple test case,each case consists of a positive integer n(1 < n < 65536),one per line.a negative terminates the input,and it should not to be processed.
Output
For each test case you should output its factor as sample output (prime factor must come forth ascending ),after each number you should output a space.There is a blank line between outputs.
Sample Input
60
12
-1
Sample Output
Case 1.
2 2 3 1 5 1
Case 2.
2 2 3 1
Hint
60=2^2*3^1*5^1
Source
hdu
这个hint 我有点看不懂 那16的话是写成 2 2 2 2 还是2 4
#include
#include
#include
int main()
{
int num;
int g=0;
while(scanf("%d",&num)!=EOF) //特别注意这行的写法
{
int i,j,k,flag,h,p,temp,m,num2;
g=g+1;
p=num;
if(num
Prime Factor
32=2^5;
16=2^4;
这个意思就是把其因式分解并写成幂的形式吧,并且因子是从小到大.