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 ...
随机推荐
- [转]全图形PPT设计指南
三.什么时候使用 全图形PPT并不适用于所有时候,一般来说,我们在以下场合可以考虑使用:陈述一个故事.名人简介.产品介绍.读书笔记.心灵鸡汤.生活情趣等. 四.如何制作全图形PPT 全图形PPT的制作 ...
- Java课程目录
Java课程目录 1 年前 大家收藏一下这篇文章,这是所有课程的目录. 第一周: 第一课:进制及计算机表示 第二课:进制习题课,进一步介绍进制的知识 第三节课:Java语言的品味(一),通过stati ...
- iOS算法笔记-快速排序-OC实现
快速排序(Quicksort)是对冒泡排序的一种改进. 快速排序由C. A. R. Hoare在1962年提出.它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另 ...
- Lua语言中文手册 转载自网络
Programming in LuaCopyright ® 2005, Translation Team, www.luachina.net Programming in LuaProgramming ...
- Java基础-6流程控制
一).选择控制: 选择控制分为两种:if...else...和switch 单分支结构:这是最简单的一种选择结构,它只是简单的判断某个条件是否成立,如果成立就执行一段代码,语句形式为: if(条件表达 ...
- Codeforces 1088E 树形dp+思维
比赛的时候看到题意没多想就放弃了.结果最后D也没做出来,还掉分了,所以还是题目做的太少,人太菜. 回到正题: 题意:一棵树,点带权值,然后求k个子连通块,使得k个连通块内所有的点权值相加作为分子除以k ...
- 学习go语言第一天
今天先下载了go语言,FQ去下载的,一开始想用eclipse,然后下载了go插件,结果出现错误,我英语水平有限,就换了liteIDE,感觉还不错,go语言环境变量因为我是msi安装的,好像可以不用自己 ...
- Axios & Interceptors & Serialization & CORS & cookie
Axios https://github.com/axios/axios#config-defaults Global axios defaults axios.defaults.baseURL = ...
- VMware 密匙
11.0版本 1F04Z-6D111-7Z029-AV0Q4-3AEH8 亲测可用
- 利用反射修改final数据域
当final修饰一个数据域时,意义是声明该数据域是最终的,不可修改的.常见的使用场景就是eclipse自动生成的serialVersionUID一般都是final的. 另外还可以构造线程安全(thre ...