1131. Copying

1131. Copying

Time Limit: 0.25 second
Memory Limit: 16 MB
A new educating program was received by the kindergarten. Of course, children have discovered it immediately and want to play with it as soon as possible. In order to let them do it the program has to be copied to all the  N computers that the kindergarten had bought just before the default of 1998. At the moment the program is installed only on one computer. Other computers do not have floppy drives and are not connected with a local network. The only way to transfer information from one computer to another is to copy it using a null-modem cable (a cable that connects two computers directly). So, if the program is installed on a computer, it can be copied to some other (but only one!) computer within an hour. There are only  K null-modem cables in the kindergarten. Your task is to estimate the minimal time necessary for copying the program to all the computers in the kindergarten.

Input

The only input line contains two integers separated with a space:  N and  K (1 ≤  N ≤ 10 9; 1 ≤  K≤ 10 9).

Output

You are to output the minimal time (in hours) necessary for copying of the program to all the computers.

Sample

input output
8 3
4

竟然忽略了一开始已经装载了这个软件的那台电脑。。。我是大SB。。

#include <iostream>
using namespace std;

int main()
{
	int n, k, h, a = 1;
	cin>>n>>k;
	n--;
	for (h=1; a<k && 2*a-1<n; h++)
		a *= 2;
	if (a >= k && a-1+k<n)
		h += (n - (a-1 + k) + k-1) /k;
	cout<<h<<endl;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值