51nod1057

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const long long maxn=1e8;
typedef long long ll;
int i,j,c,n,m;
ll a[10000];
int main(){
    scanf("%d",&n);
    a[0]=1;
    for(int i=1;i<=n;i++){
        c=0;//c表示每八位进行相乘时候的进位
        for(int j=0;j<=m;j++){//用循环来让数组中存储的数实现每八位相乘
            a[j]=a[j]*i+c;
            c=a[j]/maxn;//计算进位
            a[j]=a[j]%maxn;//更新数组的存储
        }
        if(c>0){
            m++;//m代表目前计算的答案占用了几个空间
            a[m]=c;
        }
    }
    printf("%lld",a[m]);//先输出前面的 这个不用补足八位
    for(i=m-1;i>=0;i--)
        printf("%08lld",a[i]);//不足八位的补0
    printf("\n");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/precious-ZPF/p/9483925.html