Gym 100952 B. New Job
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
一台电脑只能与另一台电脑连接,所以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的更多相关文章
- 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 ...
- codeforces gym 100952 A B C D E F G H I J
gym 100952 A #include <iostream> #include<cstdio> #include<cmath> #include<cstr ...
- Gym 100952 H. Special Palindrome
http://codeforces.com/gym/100952/problem/H H. Special Palindrome time limit per test 1 second memory ...
- 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 ...
- Gym 100952 F. Contestants Ranking
http://codeforces.com/gym/100952/problem/F F. Contestants Ranking time limit per test 1 second memor ...
- 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 ...
- Gym 100952 C. Palindrome Again !!
http://codeforces.com/gym/100952/problem/C C. Palindrome Again !! time limit per test 1 second memor ...
- 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 ...
- 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 ...
随机推荐
- OpenGL编程(五)绘直线以及分析绘直线的算法
这次主要实现在窗口上绘制点.线以及修改其属性,另外还会分析画直线的原理和相关算法. 1.在窗口指定位置画点 glBegin(GL_POINTS); glEnd(); 使用glBegin()和glEnd ...
- [BJWC2011]禁忌 AC 自动机 概率与期望
#include<cstdio> #include<algorithm> #include<cstring> #include<string> #inc ...
- php八大设计模式之桥接模式
一个抽象产生多种具体的实现方式,单纯的通过子类继承会有子类爆炸(过多的子类产生)的现象,系统需要它们之间进行动态耦合. 面向过程: <?php header("content-type ...
- Hadoop集群配置搭建
环境:Centos 6.9,Hadoop 2.7.1,JDK 1.8.0_161,Maven 3.3.9 前言: 1.配置一台master服务器,两台或多台slave服务器. 2.master可 ...
- vue-cli生成的模板各个文件详解(转)
vue-cli脚手架中webpack配置基础文件详解 一.前言 原文:https://segmentfault.com/a/1190000014804826 vue-cli是构建vue单页应用的脚手架 ...
- thymeleaf 教程
html页面 添加 <html xmlns:th="http://www.thymeleaf.org" > html原有标签都可以用thymeleaf标签替换 1.t ...
- Java基础学习总结(13)——流IO
一.JAVA流式输入/输出原理 流是用来读写数据的,java有一个类叫File,它封装的是文件的文件名,只是内存里面的一个对象,真正的文件是在硬盘上的一块空间,在这个文件里面存放着各种各样的数据,我们 ...
- js获取css
原帖地址:http://kingphp.blog.163.com/blog/static/20042324420120109438458/ 我们通过dom.style获得的属性是有限制的,只能获取ht ...
- Java的几个有用小Util函数(日期处理和http)
/** * 依据日期返回当前日期是一年的第几天 * @param date * @return */ public static int orderDa ...
- openGl超级宝典学习笔记 (2) 7个主要的几何图元
点(GL_POINTS): 点总是正方形的像素,默认情况下,点的大小不受透视除法影响. 即无论与视点的距离怎样,它的大小都不改变.为了获得圆点.必须在抗锯齿模式下绘制点. 能够用glPointSize ...