提交时间:2024-08-20 17:08:16
运行 ID: 169799
#include<stdio.h> #include<iostream> #include<math.h> #include<string.h> using namespace std; struct bign{ int d[3000]; int len; bign() { memset(d,0,sizeof(d)); len=0; } }; bign multi(bign a,int b) { bign c; //c.len--; int carry=0; for(int i=0;i<a.len;i++) { int temp=a.d[i]*b+carry; c.d[c.len++]=temp%10; carry=temp/10; } while(carry!=0){ c.d[c.len++]=carry%10; carry/=10; } return c; } int main() { int n,i; while(scanf("%d",&n)!=EOF){ bign c; c.d[0]=1; c.len=1; for(i=1;i<=n;i++) { c=multi(c,i); } for(int i=c.len-1;i>=0;i--) { printf("%d",c.d[i]); } printf("\n"); } return 0; }