hihoCoder1498-Diligent Robots

#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=2;b=1;ans=n;                             //最初假设复制了一次,两个机器人
        while(a<n){
            if(n%a==0)                             //判断一下是否整除工作量,不整除就为一个小时
               cnt=0;
            else
                cnt=1;
            ans=min(ans,b*m+n/a+cnt);
            a*=2;                                  //几个机器人
            b++;                                   //复制几次
        }
        printf("%lld\n",ans);
    }
    return 0;
}

没了==

时间: 2024-08-07 08:37:18

hihoCoder1498-Diligent Robots的相关文章

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 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 n

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

模拟. 不断分裂,然后计算时间,取个最小值.我也不知道这做法对不对的,读完题猜了一下,抱着$WA$的心态$submit$了,然后跳出一个$AC$. #include<bits/stdc++.h> using namespace std; long long n; int q; int main() { scanf("%lld%d",&n,&q); long long now=1; long long ans=n; long long ci=0; while(

Python 爬虫-Robots协议

2017-07-25 21:08:16 一.网络爬虫的规模 二.网络爬虫的限制 ? 来源审查:判断User‐Agent进行限制 检查来访HTTP协议头的User‐Agent域,只响应浏览器或友好爬虫的访问? 发布公告:Robots协议 告知所有爬虫网站的爬取策略,要求爬虫遵守 三.Robots 协议 作用:网站告知网络爬虫哪些页面可以抓取,哪些不行形式:在网站根目录下的robots.txt文件 如果网站不提供Robots协议则表示该网站允许任意爬虫爬取任意次数. 类人类行为原则上可以不遵守Rob

robots.txt的介绍和写作

目前很多网站管理者似乎对robots.txt并没有引起多大重视,甚至不知道这么一个文件的作用.本来应该保密的信息被爬虫抓取了,公布在公网上,本应该发布到公网的信息却迟迟不被搜索引擎收录.所以下面这篇文章,就来介绍robots.txt的作用和写作 robots.txt基本介绍 robots 是一个纯文本文件,是用来告诉搜索引擎:当前这个网站上哪些部分可以被访问.哪些不可以,robots文件是存放在网站根目录下的一个纯文本文件.当搜索引擎访问一个网站时,它首先会检查该网站根目录下是否存在robots

Place the Robots 需要较强的建图能力

Place the Robots 思路:在任意一个点格子放机器人,那么它所在的行和列被控制了.我们对每一行或每一列连续的空地(草地忽视)称之为块,给每一行和每一列的块标号, 每一行的快与每一列的快相交的话,才有只有一个交点.  我们把交点当边,把行块和列块连接起来.每一个空第都是一条边.详细细节见代码. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath&

django1.5添加robots.txt

方法一:(The best way) urlpatterns = patterns( (r’^robots\.txt$’, TemplateView.as_view(template_name=’robots.txt’, content_type=’text/plain’)), ) 其他: http://stackoverflow.com/questions/6867468/setting-up-mimetype-when-using-templateview-in-django

seo课程之robots.txt的格式

其实很多人刚刚开始从事seo的时候,根本就不知道什么是robots.txt,就算知道了也不懂得robots.txt的文件格式是什么,今天小编我就来和大家分享一下吧(本文来自于e良师益友网). "robots.txt"文件包含一条或更多的记录,这些记录通过空行分开(以CR,CR/NL, or NL作为结束符),每一条记录的格式如下所示: "<field>:<optional space><value><optionalspace>

UVA10599 - Robots(II)(变形的LIS)

题意:一个机器人在n * m的网格里面捡垃圾,机器人只能向右或向下走,求出能捡到的垃圾数量的最大值,有多少条路径可以达到最大值,以及输出其中一条路径. 思路:按照题意可以看出,因为机器人只能向右和向下走,所以纵坐标就不重要的,而横坐标是递增的.当将所有拥有垃圾的格子经过计算得到它的一维值(唯一的),得到一组的数组.那就可以转化为求最长上升子序列.但这个LIS的条件是mod(m)要大于前一个.计算数量时,当d[i] = d[j] + 1时,就相当于以i为结束时的最长上升子序列比以j结束时的最长上升

实例分析Robots.txt写法

题意:经典八数码问题 思路:HASH+BFS #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 500000; const int size = 1000003; typedef int State[9]; char str[30]; int state[9],goal[9]={