#1498 : Diligent Robots

Time Limit:10000ms
Case Time Limit:1000ms
Memory Limit:256MB

Description

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  

题意就是机器人完成工作,机器人可以做两种事,一个是机器人可以花一小时完成一项工作,另一个是机器人花Q小时再复制一个机器人,要求出完成工作花费的最少时间。

可以先把所有要复制的先复制完,然后再完成工作。

注意两个或两个以上的机器人在同一个工作或复制相同的机器人不会加速进展。

代码:

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n,m,a,b,ans,cnt;
while(~scanf("%lld%lld",&n,&m)){
a=;b=;ans=n; //最初假设复制了一次,两个机器人
while(a<n){
if(n%a==) //判断一下是否整除工作量,不整除就为一个小时
cnt=;
else
cnt=;
ans=min(ans,b*m+n/a+cnt);
a*=; //几个机器人
b++; //复制几次
}
printf("%lld\n",ans);
}
return ;
}

hihoCoder1498-Diligent Robots的更多相关文章

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

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

  2. HihoCoder - 1498 Diligent Robots

    There are N jobs to be finished. It takes a robot 1 hour to finish one job. At the beginning you hav ...

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

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

  4. 网站 robots.txt 文件编写

    网站 robots.txt 文件编写 Intro robots.txt 是网站根目录下的一个纯文本文件,在这个文件中网站管理者可以声明该网站中不想被robots访问的部分,或者指定搜索引擎只收录指定的 ...

  5. Robots.txt - 禁止爬虫(转)

    Robots.txt - 禁止爬虫 robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: v ...

  6. (转载)robots.txt写法大全和robots.txt语法的作用

    1如果允许所有搜索引擎访问网站的所有部分的话 我们可以建立一个空白的文本文档,命名为robots.txt放在网站的根目录下即可.robots.txt写法如下:User-agent: *Disallow ...

  7. 2016 ccpc 网络选拔赛 F. Robots

    Robots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  8. robots.txt文件没错,为何总提示封禁

    大家好,我的robots.txt文件没错,为何百度总提示封禁,哪位高人帮我看看原因,在此谢过. 我的站点www.haokda.com,robots.txt如下: ## robots.txt for P ...

  9. robots笔记以免忘记

    html头部标签写法: <meta name="robots" content="index,follow" /> content中的值决定允许抓取 ...

随机推荐

  1. 1_3 C语言解决求n!

    求n!(n为键盘输入的任意整数值).要求分别用while语句和for语句实现 用while语句实现: #include <stdio.h> int main() { int n; scan ...

  2. 599. Minimum Index Sum of Two Lists

    Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite ...

  3. Docker(五):Docker高级网络配置

    1.容器跨主机多子网方案 网络设计如下: 主机1:10.110.52.38 容器1: 192.168.0.1 vlan1 容器2: 192.168.0.2 vlan2 主机2:10.110.52.66 ...

  4. Docker(四):Docker基本网络配置

    1.Libnetwork Libnetwork提出了新的容器网络模型简称为CNM,定义了标准的API用于为容器配置网络. CNM三个重要概念: 沙盒:一个隔离的网络运行环境,保存了容器网络栈的配置,包 ...

  5. 关于foo的一个面试题

    今天看到一个关于foo的一个面试题,赶脚特别有意思 function foo(){// 第16行 getName = function(){console.log(1)} return this } ...

  6. 控制input 输入框的placeholder

    /*webkit placeholder居右*/ ::-webkit-input-placeholder { color: #e7e7e7; text-indent: .3rem; font-size ...

  7. Windows Server服务器日常管理技巧

    高效管理服务器一直离不开有效的服务器管理技巧,尽管你已经掌握了不少这方面的技巧,但服务器还有许许多多的技巧在等着你的总结,等着你的挖掘;这不,下面的一些服务器管理窍门就是笔者在最近的工作中总结出来的, ...

  8. java应用的jar包多合一

    之前开发的java程序由于依赖比较多的jar包,启动命令为" java -classpath .:lib/*.jar 主类名",这种启动方式需要指定类路径.入口类名称,并存在jar ...

  9. 关于《Web接口开发与自动化测试--基于Python语言》

    关于封面logo 首先,你会被书封上面logo吸引,这么炫酷?双蛇杖?嗯,这是Requests的新logo. 旧的logo是一只乌龟. 新logo是双蛇杖: 看到新logo我首先想到的是 火爆全网页游 ...

  10. Windows 7下将Tomcat Java程序设置为Windows Service

    可以参看以下资料: https://jingyan.baidu.com/article/b2c186c89f5127c46ef6ff08.html http://tomcat.apache.org/t ...