质因数2
Description
将一个正整数N(1<N<32768)分解质因数,把质因数按从小到大的顺序输出。最后输出质因数的个数。
Input
一行,一个正整数
Output
两行,第一行为用空格分开的质因数
第二行为质因数的个数
Sample Input 1
66
Sample Output 1
2 3 11 3
Hint
HINT:时间限制:1.0s 内存限制:256.0MB
AC代码
#include<stdio.h>
int main()
{
int a,count=0;
scanf("%d",&a);
while(a!=1)
{
for(int i=2;i<=a;i++)
{
if(a%i==0)
{
printf("%d ",i);
count++;
a=a/i;
break;
}
}
}
printf("\n%d\n",count);
}