首页 > 其他 > 详细

hihocoder1498 Diligent Robots

时间:2017-07-01 20:40:22      阅读:296      评论:0      收藏:0      [点我收藏+]

时间限制:10000ms
单点时限:1000ms
内存限制:256MB
描述
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.

输入
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

输出
The minimum number of hours.

样例输入
10 1
样例输出
5

 

题意:开局只有一个机器人,每次都可以两种操作

1.一个机器人可以完成一个任务

2.复制自己

题解:贪心,要复制必须先全部复制完后再进行工作,直接暴力就可以了

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m, t, k, ans;
    cin>>n>>m;
    t = 2,k = 1;
    ans = n;
    while(t<n){
        ans = min(ans, k*m+n/t+(n%t==0?0:1));
        t = t*2;
        k++;
    }
    cout<<ans<<endl;
    return 0;
}

 

hihocoder1498 Diligent Robots

原文:http://www.cnblogs.com/Noevon/p/7103315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!