Chinaunix首页 | 论坛 | 博客

Lzy

  • 博客访问: 208278
  • 博文数量: 56
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2014-02-27 15:50
文章分类

全部博文(56)

文章存档

2014年(56)

我的朋友

分类: C/C++

2014-11-23 14:20:54


大数N!

点击(此处)折叠或打开

  1. #include<stdio.h>
  2. #include<string.h>
  3. const int maxn = 50000;
  4. int f[maxn];
  5. int main()
  6. {
  7.     int i,j,n;
  8.     while(scanf("%d",&n)!=EOF)
  9.     {
  10.         memset(f,0,sizeof(f));
  11.         f[0]=1;
  12.         for(i=2;i<=n;i++)
  13.         {
  14.             int c=0;
  15.             for(j=0;j<maxn;j++)
  16.             {
  17.                 int s=f[j]*i+c;
  18.                 f[j]=s%10;
  19.                 c=s/10;
  20.             }
  21.         }
  22.         for(j=maxn-1;j>=0;j--)
  23.             if(f[j]) break;
  24.         for(i=j;i>=0;i--)
  25.             printf("%d",f[i]);
  26.         printf("\n");
  27.     }
  28.     return 0;
  29. }

阅读(785) | 评论(0) | 转发(0) |
0

上一篇:线程

下一篇:HDU A + B Problem II 1002

给主人留下些什么吧!~~