There are N jobs to be finished. It takes a robot 1 hour to finish one job.

At the beginning you have only one robot. Luckily a robot may build more robots identical to itself. It takes a robot Q hours to build another robot.

So what is the minimum number of hours to finish N jobs?

Note two or more robots working on the same job or building the same robot won't accelerate the progress.

Input

The first line contains 2 integers, N and Q.

For 70% of the data, 1 <= N <= 1000000

For 100% of the data, 1 <= N <= 1000000000000, 1 <= Q <= 1000

Output

The minimum number of hours.

Sample Input

10 1

Sample Output

5

解题思路:
被签到题卡了半天也是日了狗了,直接暴力就能过结果非要去推公式求导,结果还求错了。。。
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
int main()
{
ll m,q,ans=,i,t;
cin>>m>>q;
ll sum = ;
while(){
if(pow(,ans)>m)
break;
t=ans*q+m/(pow(,ans));
int num = m/pow(,ans);
if(m-pow(,ans)*num!=)
t++;
sum = min(t,sum);
ans++;
}
cout<<sum<<endl;
}

HihoCoder - 1498 Diligent Robots的更多相关文章

  1. hihoCoder #1498 : Diligent Robots【数学】

    #1498 : Diligent Robots 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 There are N jobs to be finished. It t ...

  2. 【微软2017年预科生计划在线编程笔试第二场 B】Diligent Robots

    [题目链接]:http://hihocoder.com/problemset/problem/1498 [题意] 一开始你有1个机器人; 你有n个工作; 每个工作都需要一个机器人花1小时完成; 然后每 ...

  3. hihoCoder1498-Diligent Robots

    #1498 : Diligent Robots Time Limit:10000ms Case Time Limit:1000ms Memory Limit:256MB Description The ...

  4. hihocoder -1121-二分图的判定

    hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...

  5. Hihocoder 太阁最新面经算法竞赛18

    Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus ...

  6. hihoCoder太阁最新面经算法竞赛15

    hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...

  7. 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II

    http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...

  8. 【hihocoder#1413】Rikka with String 后缀自动机 + 差分

    搞了一上午+接近一下午这个题,然后被屠了个稀烂,默默仰慕一晚上学会SAM的以及半天4道SAM的hxy大爷. 题目链接:http://hihocoder.com/problemset/problem/1 ...

  9. 【hihoCoder】1148:2月29日

    问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...

随机推荐

  1. IIS导入.pfx证书时报错:"A specified logon session does not exist. It may already have been terminated."

    在IIS中可以直接导入.pfx文件来给站点绑定https协议: 如果在导入.pfx文件时,不选择"Allow this certificate to be exported"的话 ...

  2. c#中的多线程异常 (转载)

    1.对于Thread操作的异常处理 public static void Main() { try { Thread th = new Thread(DoWork); th.Start(); } ca ...

  3. EF Core中DbContext可以被Dispose多次

    我们知道,在EF Core中DbContext用完后要记得调用Dispose方法释放资源.但是其实DbContext可以多次调用Dispose方法,虽然只有第一次Dispose会起作用,但是DbCon ...

  4. BZOJ3817 清华集训2014 Sum 类欧几里得

    传送门 令\(\sqrt r = x\) 考虑将\(-1^{\lfloor d \sqrt r \rfloor}\)魔改一下 它等于\(1-2 \times (\lfloor dx \rfloor \ ...

  5. Luogu4700 CEOI2011 Traffic Tarjan、搜索

    传送门 题意:给出平面上$N$个点,它们一定在左下角为$(0,0)$,右上角为$(A,B)$的一个矩形内的整点上(包括边界),而且会给出$M$条呈直线的边,其中有有向边也有无向边,保证任意两条边不会在 ...

  6. sessionStorage和localStorage的区别

    JS的本地保存localStorage.sessionStorage用法总结 localStorage.sessionStorage是Html5的特性,IE7以下浏览器不支持 为什么要掌握localS ...

  7. Verilog对数据进行四舍五入(round)与饱和(saturation)截位

    转自https://www.cnblogs.com/liujinggang/p/10549095.html 一.软件平台与硬件平台 软件平台: 操作系统:Windows 8.1 64-bit 开发套件 ...

  8. 使用IdentityServer4实现一个简单的Oauth2客户端模式授权

    1.首先新建一个webAPI项目做为IdentityServer的服务端,提供生成Token的服务,首先修改Startup.cs文件,如下图: 2.增加一个Config.cs文件,以便于提供资源和认证 ...

  9. 系统、决策、控制研究系列(SSDC)

    本类目主要介绍的书籍来自springer的系列书籍中的一本,对于该系列书籍介绍如下: “系统.决策及控制研究”(SSDC)系列涵盖了在广泛认知的系统.决策及控制的各个领域的快速.最新和高质量的最新发展 ...

  10. [Android]记录一次处理app:transformDexArchiveWithExternalLibsDexMergerForDebug错误

    第一种情况: Android 目录结构如下: app中build.gradle包含: implementation 'com.squareup.okhttp3:okhttp:3.6.0' implem ...