加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

LightOj 1045 大数处理

发布时间:2020-12-14 02:06:22 所属栏目:大数据 来源:网络整理
导读:LightOj 1045 题目链接: http://lightoj.com/volume_showproblem.php?problem=1045 题意: 给n和base,求n!在base进制下最大位数。 思路: 看题解。 用log表示特别大的数,然后答案时log(n)/log(base)+1 源码: #include cstdio #include cstring #include

LightOj 1045
题目链接:
http://lightoj.com/volume_showproblem.php?problem=1045
题意:
给n和base,求n!在base进制下最大位数。
思路:
看题解。
用log表示特别大的数,然后答案时log(n)/log(base)+1
源码:

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
const int MAXN = 1000000 + 5;
double fac[MAXN];
int main()
{
    fac[0] = 0;
    for(int i = 1 ; i < MAXN ; i++) fac[i] = fac[i - 1] + log(1.0 * i);
    int T;
    scanf("%d",&T);
    for(int cas = 1 ; cas <= T ; cas++){
        int n,m;
        scanf("%d%d",&n,&m);
        int ans = fac[n] / log(1.0 * m) + 1;
        printf("Case %d: %dn",cas,ans);
    }
    return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读