其实大数的问题还是用java做好,简单暴力。
直接上代码:
#include<iostream>
using namespace std;
const int maxn = 10000;
int main()
{
int n,m;
while(cin>>n)
{
int f[maxn];
memset(f,0,sizeof(f));
f[0] = 1;
for(int i=2;i<=n;i++)
{
int c=0;//用来进位
for(int j=0;j<maxn;j++)
{
int s = f[j] * i + c;
f[j] = s % 10;
c = s /10;
}
}
for(m=maxn-1;m>=0;m--) if(f[m]) break;
for(int i=m;i>=0;i--)
cout<<f[i];
cout<<endl;
}
}