码迷,mamicode.com
首页 > 其他好文 > 详细

51nod1057

时间:2018-08-15 21:05:14      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:51nod   typedef   stdio.h   str   amp   pac   main   for   stream   

#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;
}

 

51nod1057

标签:51nod   typedef   stdio.h   str   amp   pac   main   for   stream   

原文地址:https://www.cnblogs.com/precious-ZPF/p/9483925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!