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
Note

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.

题目链接:http://codeforces.com/gym/100952/problem/B

题意:将一个文件复制到n台电脑上,但是只有m条网线,每台电脑一次只能连接一根网线,输出多少时间可以完成复制!

分析:模拟一下就好了!
下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
inline ll gcd(ll x,ll p,ll mod)
{
ll cnt=;
for(;p;p>>=,x=x*x%mod)
{
if(p&)
cnt=cnt*x%mod;
}
return cnt;
}
ll n,m;
int main()
{
int t;
t=read();
while(t--)
{
ll ans=;
n=read();
m=read();
ll tim=;
while()
{
if(tim>=m)
{
tim=m;
ans+=(n/tim);
if(n%tim)
ans++;
break;
}
ans++;
n-=tim;
tim=tim*;
if(n<=)
break;
}
cout<<ans<<endl;
}
return ;
}

Gym 100952B&&2015 HIAST Collegiate Programming Contest B. New Job【模拟】的更多相关文章

  1. Gym 100952I&&2015 HIAST Collegiate Programming Contest I. Mancala【模拟】

    I. Mancala time limit per test:3 seconds memory limit per test:256 megabytes input:standard input ou ...

  2. Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】

    E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...

  3. Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】

    F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standar ...

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

  5. Gym 100952H&&2015 HIAST Collegiate Programming Contest H. Special Palindrome【dp预处理+矩阵快速幂/打表解法】

    H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard ...

  6. Gym 100952G&&2015 HIAST Collegiate Programming Contest G. The jar of divisors【简单博弈】

    G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standa ...

  7. Gym 100952D&&2015 HIAST Collegiate Programming Contest D. Time to go back【杨辉三角预处理,组合数,dp】

    D. Time to go back time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  8. Gym 100952C&&2015 HIAST Collegiate Programming Contest C. Palindrome Again !!【字符串,模拟】

    C. Palindrome Again !! time limit per test:1 second memory limit per test:64 megabytes input:standar ...

  9. Gym 100952A&&2015 HIAST Collegiate Programming Contest A. Who is the winner?【字符串,暴力】

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

随机推荐

  1. Data Base mongodb高版本与低版本的区别

    mongodb高版本与低版本的区别 一.mongodb引擎: Mongodb 3.0支持用户自定义存储引擎,用户可配置使用mmapv1或者wiredTiger存储引擎. 3.2版本以后默认的开启的是w ...

  2. 在 ReactNative 的 App 中,集成 Bugly 你会遇到的一些坑

    一.前言 最近开新项目,准备尝试一下 ReactNative,所以前期做了一些调研工作,ReactNative 的优点非常的明显,可以做到跨平台,除了少部分 UI 效果可能需要对不同的平台进行单独适配 ...

  3. LINUX:alias命令详解

    发现目前安装的g++并没有开启选项 -std=c++11,无法使用c++11的新标准及其中的列表初始化.搜索后得到解决方法:键入:alias  g++="g++ -std=c++11&quo ...

  4. Cat 客户端采用什么策略上报消息树

    策略分类 目前搞清楚两种 第一种(蓝色):默认服务器列表中选一个,算法核心是根据应用名的哈希值取模.也就是说同一个应用始终打到同一台服务器上,如果这台服务器挂了,另选一台服务器. 第二种(红色):应用 ...

  5. Spring Boot实战之数据库操作

    上篇文章中已经通过一个简单的HelloWorld程序讲解了Spring boot的基本原理和使用.本文主要讲解如何通过spring boot来访问数据库,本文会演示三种方式来访问数据库,第一种是Jdb ...

  6. 4、树莓派的中文:安装ftp,安装gcc,安装qt,编译qt程序,运行qt界面程序

    本博文仅作本人操作过程的记录,留作备忘.自强不息 QQ1222698 1.安装FTP:sudo apt-get install vsftpd 2.配置FTP,修改,/etc/vsftpd.conf # ...

  7. [摘抄]VC6.0移植到VS2008(vs2005)后的错误总结(未全部验证)

    ============================================================================================= 201405 ...

  8. Mysql中字符集总结

    有时候,在Mysql数据库中会经常遇到乱码的问题,现在普遍的做法就是全部强行把编码格式都设置成utf8模式,就可以解决这个问题,以前是知其然,不知其所以然,今天我就稍微研究了下Mysql的字符集. 就 ...

  9. Python学习_06_文件、IO

    文件对象 python中的文件操作和c语言比较类似,包括一些缓冲.偏移量的方式. 文件对象可以通过open().file()两个内建方法创建,两个方法并没有什么不同,使用方法和c语言中的fopen() ...

  10. [Python学习] Django 权限控制

    本文为大家讲解 Django 框架里自带的权限模型,从理论到实战演练,带领大家了解 Django 里权限是怎么一回事. 一.主要内容 1.什么是权限管理? 2.Web 权限 3.Django 权限机制 ...