标签:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long LL;
const LL MOD = 100000000000000;///省时间
const int MAXN = 40000;
LL a[MAXN];
int main()
{
int n;
while(cin>>n)
{
memset(a, 0, sizeof(a));
a[0] = 1;
int end = 0;
for(LL i=2; i<=n; i++)
{
LL c = 0;///进位
for(LL j=0; j<=end; j++)///注意这里是个窍门
{
LL s = a[j]*i+c;
a[j] = s%MOD;
c = s/MOD;
}
if(c)
a[++end] = c;
}
printf("%lld",a[end]);
for(LL i=end-1; i>=0; i--)
{
printf("%014I64d",a[i]);
}
puts("");
}
return 0;
}
标签:
原文地址:http://blog.csdn.net/qingshui23/article/details/51334625