应改有更科学的方法吧~~我就是纯高精度了~~稍微估计了一下~~只做到1000位~~每次加进来都吧后缀0去掉~~最终输出第一位就ok了~~
Program:
/*
ID: zzyzzy12
LANG: C++
TASK: fact4
*/
#include<iostream>
#include<istream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<algorithm>
#include<queue>
#define oo 2000000000
#define ll long long
using namespace std;
int a[1005],n;
void mul(int k)
{
int i,m;
for (i=1;i<=1000;i++) a[i]*=k;
i=1;
for (i=1;i<1000;i++)
{
a[i+1]+=a[i]/10;
a[i]%=10;
}
a[1000]%=10;
for (m=1;m<1000;m++)
if (a[m]!=0) break;
m--;
if (m)
for (i=1;i<1000-m;i++)
{
a[i]=a[i+m];
a[i+m]=0;
}
}
int main()
{
freopen("fact4.in","r",stdin);
freopen("fact4.out","w",stdout);
memset(a,0,sizeof(a));
a[1]=1;
scanf("%d",&n);
for (int i=1;i<=n;i++)
mul(i);
printf("%d\n",a[1]);
return 0;
}