九度教程第61题
C语言源码:
[cpp]
#include<stdio.h>
#define maxsize 1000
#define size 1000000
int a[maxsize],b[maxsize];
int main()
{
int n,i,j,len;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<maxsize;i++)
a[i]=0;
a[0]=1;
len=1;
i=2;
while(i<=n)
{
for(j=0;j<maxsize;j++)
b[j]=0;
j=0;
while(j<len)
{
b[j]+=a[j]*i;
if(b[j]>=size)
{
b[j+1]+=b[j]/size;
b[j]=b[j]%size;
}
j++;
}
j=len;
while(j<len+4)
{
if(b[j]>=size)
{
b[j+1]+=b[j]/size;
b[j]=b[j]%size;
}
j++;
}
len=len+4;
while(b[len-1]==0)
len--;
for(j=0;j<len;j++)
a[j]=b[j];
i++;
}
for(i=len-1;i>=0;i--)
{
if(i!=len-1)
printf("%06d",a[i]);
else
printf("%d",a[i]);
}
printf("\n");
}
}
补充:软件开发 , C++ ,