其实就是大整数和非大整数相乘
要注意更新数组长度
#include<iostream>
#include<cstring>
#define maxn 40002
using namespace std;
static int sum[maxn];
void cal(int n){
memset(sum,0,sizeof(sum));
int len = 1;
sum[0] = 1;
int ca = 0;
for(int i = 1;i<=n;i++){
for(int j = 0;j<len;j++){
sum[j] *= i;
sum[j] += ca;
ca = sum[j]/10;
sum[j] %= 10;
}
while(ca){
sum[len++] = ca%10;
ca/=10;
}
}
for(int i = len-1;i>=0;i--){
printf("%d",sum[i]);
}
printf("\n");
}
int main(){
int n;
while(~scanf("%d",&n)){
cal(n);
}
return 0;
}