zoukankan      html  css  js  c++  java
  • hihocoder 1498 签到

    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


     1 #include <iostream>
     2 
     3 using namespace std;
     4 
     5 int main()
     6 {   long long n,m,t,k,ans;
     7      cin>>n>>m;
     8      t=2,k=1;
     9      ans=n;
    10      while(t<n){
    11         ans=min(ans,k*m+n/t+(n%t==0?0:1));
    12         t=t*2;
    13         k++;
    14      }
    15      cout<<ans<<endl;
    16     return 0;
    17 }
  • 相关阅读:
    CSUOJ 1081 集训队分组
    HDU 1865 More is Better
    HDU 1325 Is It A Tree?
    HDU 1272 小希的迷宫
    CSUOJ 1217 奇数个的那个数
    CSUOJ 1010 Water Drinking
    CSUOJ 1162 病毒
    CodeForces 295B
    CodeForces 20C
    SPOJ MULTQ3
  • 原文地址:https://www.cnblogs.com/z-712/p/7323988.html
Copyright © 2011-2022 走看看