题目链接:点我转移
#include<cstdio> #include<cstring> #define q 200000 int main() { int n,a[q],i,j,k,m; while(scanf("%d",&n)!=EOF) { k=1; memset(a,0,sizeof(a));///把数组清0 a[1] = 1; for (i=1; i<=n; i++) { for (m=1; m<=k; m++)///将每一位乘i,之后再将进行进位 a[m] = a[m]*i; for(j=1; j<=k+10; j++) while(a[j]>9)///进位操作 { a[j+1] += a[j]/10; a[j] = a[j]%10; j=j+1; k = j; } } for(i=k; i>0; i--) printf("%d",a[i]); printf(" "); } return 0; }