[恢]hdu 1405

2011-12-20 05:26:53

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1405

题意:分解素因子。

mark:PE2次。每行最后有一个空格。太无聊了- -。

代码:

# include <stdio.h>


void output(int n)
{
int i, cnt ;
for (i = 2 ; n != 1 ; i++)
{
if (n%i==0)
{
cnt = 0 ;
while (n%i==0){cnt++; n/=i;}
printf ("%d %d ", i, cnt) ;
}
}
printf ("\n") ;
}


int main ()
{
int n, nCase = 1;
while (~scanf ("%d", &n) && n >= 2)
{
if (nCase != 1) printf ("\n") ;
printf ("Case %d.\n", nCase++) ;
output(n) ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2315258.html