Codeforces Gym100952 B. New Job (2015 HIAST Collegiate Programming Contest)
1 second
64 megabytes
standard input
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.
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.
3
10 10
7 2
5 3
4
4
3
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.
题意就是复印文件,电缆有限,然后就是在电缆数允许的情况下1台电脑复印之后就有2台电脑可以继续进行复印,然后就是4台。。。达到电缆数所允许的最大值的时候剩下的就是按电缆数进行复印。
ヾ(。`Д´。),写这个题的时候智商不在家,wa了好几次。
代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3 int main(){
4 int t,n,m,i,cnt,ans;
5 scanf("%d",&t);
6 while(t--){
7 scanf("%d%d",&n,&m);
8 cnt=1;
9 for(i=0;n>0;i++){
10 if(cnt>m)n-=m;
11 else{
12 n-=cnt;
13 cnt*=2;
14 }
15 }
16 printf("%d\n",i);
17 }
18 return 0;
19 }
Codeforces Gym100952 B. New Job (2015 HIAST Collegiate Programming Contest)的更多相关文章
- 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 ...
- 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 ...
- Codeforces Gym100952 A.Who is the winner? (2015 HIAST Collegiate Programming Contest)
A. Who is the winner? time limit per test 1 second memory limit per test 64 megabytes input stan ...
- Codeforces Gym100952 D. Time to go back-杨辉三角处理组合数 (2015 HIAST Collegiate Programming Contest)
D. Time to go back time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Gym100952 C. Palindrome Again !!-回文字符串 (2015 HIAST Collegiate Programming Contest)
C. Palindrome Again !! time limit per test 1 second memory limit per test 64 megabytes input sta ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 四大VDI客户端 总有一款适合你
[TechTarget中国原创] 交付虚拟桌面时IT管理员必须要考虑到用户如何访问虚拟桌面,因为这会影响用户体验以及VDI部署最终的成败. IT可以转向简便的HTML5客户端,HTML 5客户端功能丰 ...
- vim基本配置备份
我的vim基本配置如下,在这里作个备份: set background=light syntax on set number set smartindent set expandtab set tab ...
- 【Minimum Window】cpp
题目: Given a string S and a string T, find the minimum window in S which will contain all the charact ...
- 云计算之路-阿里云上:SLB引起的https访问速度慢问题
自从我们在阿里云SLB上部署了https之后(详见在SLB上部署https遇到的问题及解决方法),陆续有园友向我们反馈登录时速度很慢(登录时是通过https访问),有些园友甚至无法访问登录页面. 而我 ...
- python 学习分享-rabbitmq
一.RabbitMQ 消息队列介绍 RabbitMQ也是消息队列,那RabbitMQ和之前python的Queue有什么区别么? py 消息队列: 线程 queue(同一进程下线程之间进行交互) 进程 ...
- 电脑显卡4种接口类型:VGA、DVI、HDMI、DP
电脑显卡全称显示接口卡(Video card,Graphics card),又称为显示适配器(Video adapter),显示器配置卡简称为显卡,是个人电脑最基本组成部分之一.对于显卡接口类型,主要 ...
- excel模板解析—桥接模式:分离解析模板和业务校验
在做excel模板解析的时候,其实会有两个部分,第一,将模板读取出来,校验一些必录项等. 但除了这些,在数据真正被业务线使用的时候,还会有一些其他的校验,比如说:根据业务,年龄是不能超过多少岁的,包括 ...
- static_cast AND dynamic_cast
类型转换是一种机制,让程序员能够暂时或永久性改变编译器对对象的解释.注意,这并不意味着程序员改变了对象本身,而只是改变了对对象的解释. 在很多情况下,类型转换是合理的需求,可解决重要的兼容问题.因此, ...
- 01、dos命令行的常用命令
cd 进入指定目录cd.. 返回上一级目录cd\ 退回盘符根目录dir 列出当前目录下的文件以及文件夹md 创建目录rd 删除目录del 删除文件cls ...
- asp+access win2008php+mysql /dedecms 配置总结
1. IIS 应用池 高级设置 启用32位应用程序:True 2. c盘window/Temp user 应该有管理权限 如果不行 creator owner 给予修改权限 ...