http://acm.hdu.edu.cn/showproblem.php?pid=1042

#include<stdio.h>
#include<math.h>
int main()
{
	long m,i,j,a[10000],w,n,c;
	while(scanf("%ld",&n)>0)
	{
		a[0]=1;
		m=0;
		for(i=1;i<=n;i++)
		{
			c=0;
			for(j=0;j<=m;j++)
			{
				a[j]=a[j]*i+c;    //关键语句
				c=a[j]/10000;
				a[j]%=10000;
			}
			if(c>0)
			{
				m++;
				a[m]=c;
			}
		}
		w=m*4+log10((double)a[m])+1;   //计算有多少个数
		printf("%ld",a[m]);
		for(i=m-1;i>=0;i--)
			printf("%4.4ld",a[i]);
		printf("\n");
	}
	return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2021-10-09
  • 2021-10-28
  • 2021-06-28
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2022-01-19
  • 2021-08-19
  • 2021-06-08
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案