大数阶乘题
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1042
#include<stdio.h> #include<string.h> const int maxn=50000; int a[maxn]; int main() { int i,j,n; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); a[0]=1; for(i=2;i<=n;i++) { int up=0;//**up代表进位**// for(j=0;j<maxn;j++) { int s=a[j]*i+up; a[j]=s%10; up=s/10; } } for(j=maxn-1;j>=0;j--) if(a[j]) break;//**去掉前面多余的0**// for(i=j;i>=0;i--) printf("%d",a[i]); printf("\n"); } return 0; }