ecjtu-summer training #6 B
来源:互联网 发布:特朗普移民政策 知乎 编辑:程序博客网 时间:2024/06/06 03:44
This is the first day for you at your new job and your boss asks you to copy some files from one computer to other computers in an informatics laboratory. He wants you to finish this task as fast as possible. You can copy the files from one computer to another using only one Ethernet cable. Bear in mind that any File-copying process takes one hour, and you can do more than one copying process at a time as long as you have enough cables. But you can connect any computer to one computer only at the same time. At the beginning, the files are on one computer (other than the computers you want to copy them to) and you want to copy files to all computers using a limited number of cables.
First line of the input file contains an integer T (1 ≤ T ≤ 100) which denotes number of test cases. Each line in the next T lines represents one test case and contains two integers N, M.
N is the number of computers you want to copy files to them (1 ≤ N ≤ 1,000,000,000). While M is the number of cables you can use in the copying process (1 ≤ M ≤ 1,000,000,000).
For each test case, print one line contains one integer referring to the minimum hours you need to finish copying process to all computers.
310 107 25 3
443
In the first test case there are 10 computer and 10 cables. The answer is 4 because in the first hour you can copy files only to 1 computer, while in the second hour you can copy files to 2 computers. In the third hour you can copy files to 4 computers and you need the fourth hour to copy files to the remaining 3 computers.
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--){
int a,b,i,j,s,m;
cin>>a>>b;
s=0,m=0,j=0;
for(i=1;i<=b;i*=2){
s+=i;
m++;
}
if(a>=s){
int t=a-s;
if(t%b==0){
j+=t/b+m;
}
else j+=t/b+1+m;
}
else if(a<s){
for(i=1;i<=b;i*=2){
a-=i;
j++;
if(a<=0){
break;
}
}
}
cout<<j<<endl;
}
return 0;
}
- ecjtu-summer training #6 B
- ecjtu-summer training #5 B
- ecjtu-summer training #6 F
- ecjtu-summer training #1 B(CodeForces 651B)
- ecjtu-summer training #2 A
- ecjtu-summer training #2 D
- ecjtu-summer training #5 D
- ecjtu-summer training #5 C
- ecjtu-summer training #5 F
- ecjtu-summer training #5 A
- ecjtu-summer training #5 E
- ecjtu-summer training #1 F (UVA 11461)
- ecjtu-summer training #4 C UESTC
- ecjtu-summer training #1 A(CodeForces 651A)
- ecjtu-summer training #3 A Sort it HDU 2689
- ecjtu-summer training #3 C 又见GCD HDU 2504
- ecjtu-summer training #3 D Gym 100952A 签到题
- ecjtu-summer training #3 F HDU 1312 Red and Black
- GetClientRect()和GetWindowRect()
- sql 常用基础语句
- 使用程序生成财务预制凭证的方法(三)
- python --socket(二)粘包
- 第10讲 mysql删除数据
- ecjtu-summer training #6 B
- CSS Sticky Footer
- springmvc入门程序--不直接使用springmvc支持,而是手动加入所需jar包
- 区间dp学习、
- ua.c:80:31: fatal error: readline/readline.h: No such file or directory
- 用驱动精灵修复哈,在重新装系统
- iDempiere汉化
- HDU 1269 迷宫城堡【Tarjan强连通分量 模板】
- 各区块链架构的横向比较