#include <cstdio>
#include <cstring>
const int maxn = 3000;
int a[maxn];
int main(){
memset(a, 0, sizeof(a));
a[0] = 1;
int n = 0;
scanf("%d", &n);
for (int i = 2; i <= n; ++i){
int c = 0;
for (int j = 0; j < maxn; ++j){
int tmp = a[j] * i + c;
c = tmp / 10;
a[j] = tmp % 10;
}
}
int i = maxn - 1;
while (a[i] == 0){
--i;
}
while (i >= 0){
printf("%d", a[i--]);
}
printf("\n");
return 0;
}
算法竞赛入门经典 5.2.2高精度阶乘
最新推荐文章于 2018-01-21 12:32:00 发布