您的位置:首页 > 其它

N!

2015-08-11 10:28 405 查看

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

#include<iostream>

#include<cstring>

#include<cstdio>

using namespace std;

int a[8010];

int main()

{

// freopen("C:\\Users\\John\\Desktop\\hi.txt","r",stdin);

 int n;

 int i=1;

 while(cin>>n)

 {

  int k=0,j;

  memset(a,0,sizeof(a));

  a[1]=1;

  for(j=1;j<=n;j++)

  {

   for(i=1;i<=8000;i++)

   {

    a[i]=a[i]*j+k;

    k=a[i]/100000;

    a[i]%=100000;

   }

   

  }

  for(i=8000;;i--)

  if(a[i]!=0)

  break;

  cout<<a[i];

  i--;

  for(;i>=1;i--)

  printf("%05d",a[i]);

  cout<<endl;

 }

 return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: