B. New Job
time limit per test

1 second

memory limit per test

64 megabytes

input

standard input

output

standard output

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.

Input

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).

Output

For each test case, print one line contains one integer referring to the minimum hours you need to finish copying process to all computers.

Examples
Input
3
10 10
7 2
5 3
Output
4
4
3
一台电脑只能与另一台电脑连接,所以t*=2,当电线用完后,将以链接的电脑减去,不带复制m即可
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int dp[];
int a[],t;
int main()
{
ll t,n,m;
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld",&n,&m);
n;
ll pos=;
ll ans=;
ll cnt=;
for(ll i=;;i++)
{
if(m<=cnt)
{
cnt=m;
ans++;
pos+=cnt;
if(pos>=n)
{
cout<<ans<<endl;
break;
}
if((n-pos)%cnt==) ans+=(n-pos)/cnt;
else ans+=(n-pos)/cnt+;
cout<<ans<<endl;
break;
}
ans++;
pos+=cnt;
if(pos>=n)
{
cout<<ans<<endl;
break;
}
cnt*=;
}
}
return ;
}

Gym 100952 B. New Job的更多相关文章

  1. Gym 100952 D. Time to go back(杨辉三角形)

    D - Time to go back Gym - 100952D http://codeforces.com/gym/100952/problem/D D. Time to go back time ...

  2. codeforces gym 100952 A B C D E F G H I J

    gym 100952 A #include <iostream> #include<cstdio> #include<cmath> #include<cstr ...

  3. Gym 100952 H. Special Palindrome

    http://codeforces.com/gym/100952/problem/H H. Special Palindrome time limit per test 1 second memory ...

  4. Gym 100952 G. The jar of divisors

    http://codeforces.com/gym/100952/problem/G G. The jar of divisors time limit per test 2 seconds memo ...

  5. Gym 100952 F. Contestants Ranking

    http://codeforces.com/gym/100952/problem/F F. Contestants Ranking time limit per test 1 second memor ...

  6. Gym 100952 D. Time to go back

    http://codeforces.com/gym/100952/problem/D D. Time to go back time limit per test 1 second memory li ...

  7. Gym 100952 C. Palindrome Again !!

    http://codeforces.com/gym/100952/problem/C C. Palindrome Again !! time limit per test 1 second memor ...

  8. Gym 100952 A. Who is the winner?

    A. Who is the winner? time limit per test 1 second memory limit per test 64 megabytes input standard ...

  9. Gym 100952J&&2015 HIAST Collegiate Programming Contest J. Polygons Intersection【计算几何求解两个凸多边形的相交面积板子题】

    J. Polygons Intersection time limit per test:2 seconds memory limit per test:64 megabytes input:stan ...

随机推荐

  1. 运营商 WLAN

    运营商 WLAN 运营商 WLAN 是 Android 9 中引入的一项功能,该功能可让设备自动连接到运营商实现的 WLAN 网络.在高度拥塞或信号覆盖范围较小的区域(如体育场或地铁站),运营商 WL ...

  2. 了解Linux的基础知识和一般概念

    1.GNU和GPL    GNU计划(又称革奴计划),是由Richard Stallman(理查德·斯托曼)在1983年9月27日公开发起的自由软件集体协作计划.它的目标是创建一套完全自由的操作系统. ...

  3. MNIST手写数字数据集

    下载python源代码之后,使用: import input_data mnist = input_data.read_data_sets('MNIST_data/',one_hot=True) 下载 ...

  4. error_reporting()函数

    定义和用法 error_reporting() 函数跪地你给应该报告何种 PHP 错误. error_reporting() 函数能够在运行时设置 error_reporting 指令. PHP 有诸 ...

  5. POJ 1723 SOLDIERS

    SOLDIERS Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 1 ...

  6. Windows安装两个mysql数据库步骤

    因为新旧项目数据库版本号差距太大.编码格式不同.引擎也不同,所以仅仅好装两个数据库. 本次安装两个mysql数据库.版本号各自是4.0.18,5.5.36.都是可运行文件直接安装. 本机上之前已经安装 ...

  7. PPAPI中使用Chromium的3D图形接口

    使用PPAPI的Graphics 3D接口做了一个小演示样例,鼠标点击插件区域.绘制颜色,效果与ppapi_simple相似. foruok原创,如需转载请关注foruok的微信订阅号"程序 ...

  8. Docker Network Configuration 高级网络配置

    Network Configuration TL;DR When Docker starts, it creates a virtual interface named docker0 on the ...

  9. poj--1459--Power Network(最大流,超级源超级汇)

    Power Network Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit ...

  10. POJ2411 状态压缩dp

    POJ2411 http://poj.org/problem?id=2411