hihocode——#1498 : Diligent Robots

http://hihocoder.com/problemset/problem/1498

#1498 : Diligent Robots

时间限制: 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

假设生了k次机器人,那么时间就是n/2^k+k*q

n,q已知,那么枚举k就行~~

#include
using namespace std;
int a[100005];
int b[100005];
typedef long long LL;
int main()
{
    LL n,q;
    cin>>n>>q;
    if(n<=2*q)
    {
        cout<n)
            {
                break;
            }
            if(n%hour==0)
            {
                ans=min(ans,(n/hour)+k*q);
            }
            else
            {
                ans=min(ans,(n/hour)+1+k*q);
            }
        }
        cout<




你可能感兴趣的:(acm)