坑爹的格式!!
每个数后面都有一个空格,并且除第一组外其他组后都有一个空行!!
#include"stdio.h"
#include"math.h"
#include"string.h"
int prime[65537];
void fun()
{
int i,j,flag;
memset(prime,0,sizeof(prime));
for(i=2;i<65537;i++)
{
flag=1;
for(j=2;j<=i/2;j++)
if(i%j==0)
{
flag=0;break;
}
if(flag)
prime[i]=1;
}
}
int main()
{
int cou[65539];
int i,j,cas,count;
int n,nn;
fun();
cas=0;
while(scanf("%d",&n)!=EOF,n>0)
{
if(cas!=0)
printf("\n");
count=0;
nn=n;
cas++;
printf("Case %d.\n",cas);
memset(cou,0,sizeof(cou));
for(i=2;i<=n;i++)
{
while(prime[i]==1)
{
if(nn%i!=0) break;
else
{
cou[i]++;
nn=nn/i;
}
}
}
for(j=2;j<=n;j++)
{
if(cou[j])
{
printf("%d %d ",j,cou[j]);
continue;
}
}
printf("\n");
}
return 0;
}