# 1057 N的阶乘

#include <stdio.h>
#define _MAX 100000000
int main()
{
int n, i, j, m;
long long a[10000], c;
scanf("%d",&n);

m = 0;
a[0] = 1;
for(i = 1; i <= n; i++)
{
c = 0;
for(j = 0; j <= m; j++)
{
a[j] = a[j] * i + c;
c = a[j] / _MAX;
a[j] %= _MAX;
}
if(c > 0)
{
m++;
a[m] = c;
}
}
printf("%lld", a[m]);
for(i = m - 1; i >= 0; i--)
printf("%0.8lld", a[i]);
printf("\n");
return 0;
}

#include<stdio.h>
int a[9999]={1,0},n,i,c,len,j;
int main()
{
scanf("%d", &n);
for ( len=1,j=2;j<=n; ++j)
{
for (c=0,i=0; i<len;++i)
{
a[i]= ( c+= a[i]*j ) % 100000; c/=100000;
}
if((a[i]=c)>0)++len;
}
printf("%d",a[--len]);
for(;len;)
printf("%05d", a[--len]);
return 0;
} 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include<stdio.h>
#include<math.h>
using namespace std;
#define ll long long
#define N 1000005
#define mod 100000000000000

ll ans[10000000];

int main()
{
#ifdef DONOTKNOW
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ll n;
scanf("%I64d",&n);
ll i,j;
ll l=0;
ans[0]=1;
for(i=1; i<=n; i+=1)
{
ll c=0;
for(j=0; j<=l; j+=1)
{
ll t=ans[j]*i+c;
ans[j]=t%mod;
c=t/mod;
}
if(c!=0)
{
ans[++l]=c;
}
}
printf("%I64d",ans[l]);
for(i=l-1; i>=0; i-=1)
{
printf("%0.14I64d",ans[i]);
}
return 0;
}