CF1606B.Update Files
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Berland State University has received a new update for the operating system. Initially it is installed only on the 1-st computer.
Update files should be copied to all n computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy them using a patch cable (a cable connecting two computers directly). Only one patch cable can be connected to a computer at a time. Thus, from any computer where the update files are installed, they can be copied to some other computer in exactly one hour.
Your task is to find the minimum number of hours required to copy the update files to all n computers if there are only k patch cables in Berland State University.
贝兰德国立大学收到了操作系统的最新更新。最初,该更新仅安装在第 1 台计算机上。
更新文件需复制到全部 n 台计算机。由于这些计算机未连接互联网,因此将更新文件从一台计算机传输到另一台计算机的唯一方式是使用网线(即直接连接两台计算机的电缆)。每台计算机同一时刻最多只能连接一根网线。因此,对于任意一台已安装更新文件的计算机,均可在恰好一小时内将更新文件复制到另一台计算机。
你的任务是:若贝兰德国立大学仅有 k 根网线,求将更新文件复制到全部 n 台计算机所需的最少小时数。
输入格式
The first line contains a single integer t (1≤t≤105) — the number of test cases.
Each test case consists of a single line that contains two integers n and k (1≤k≤n≤1018) — the number of computers and the number of patch cables.
第一行包含一个整数 t(1≤t≤105)—— 测试用例的数量。
每个测试用例由一行组成,该行包含两个整数 n 和 k(1≤k≤n≤1018)—— 计算机的数量和补丁电缆的数量。
输出格式
For each test case print one integer — the minimum number of hours required to copy the update files to all n computers.
对于每个测试用例,输出一个整数——将更新文件复制到所有 n 台计算机所需的最少小时数。
输入输出样例
输入#1
4 8 3 6 6 7 1 1 1
输出#1
4 3 6 0
说明/提示
Let's consider the test cases of the example:
- n=8, k=3:
- during the first hour, we copy the update files from the computer 1 to the computer 2;
- during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4;
- during the third hour, we copy the update files from the computer 1 to the computer 5, from the computer 2 to the computer 6, and from the computer 3 to the computer 7;
- during the fourth hour, we copy the update files from the computer 2 to the computer 8.
- n=6, k=6:
- during the first hour, we copy the update files from the computer 1 to the computer 2;
- during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4;
- during the third hour, we copy the update files from the computer 1 to the computer 5, and from the computer 2 to the computer 6.
- n=7, k=1:
- during the first hour, we copy the update files from the computer 1 to the computer 2;
- during the second hour, we copy the update files from the computer 1 to the computer 3;
- during the third hour, we copy the update files from the computer 1 to the computer 4;
- during the fourth hour, we copy the update files from the computer 4 to the computer 5;
- during the fifth hour, we copy the update files from the computer 4 to the computer 6;
- during the sixth hour, we copy the update files from the computer 3 to the computer 7.
我们来考虑示例中的测试用例:
- n=8,k=3:
- 第一小时内,我们将更新文件从计算机 1 复制到计算机 2;
- 第二小时内,我们将更新文件从计算机 1 复制到计算机 3,并同时从计算机 2 复制到计算机 4;
- 第三小时内,我们将更新文件从计算机 1 复制到计算机 5,从计算机 2 复制到计算机 6,并从计算机 3 复制到计算机 7;
- 第四小时内,我们将更新文件从计算机 2 复制到计算机 8。
- n=6,k=6:
- 第一小时内,我们将更新文件从计算机 1 复制到计算机 2;
- 第二小时内,我们将更新文件从计算机 1 复制到计算机 3,并同时从计算机 2 复制到计算机 4;
- 第三小时内,我们将更新文件从计算机 1 复制到计算机 5,并从计算机 2 复制到计算机 6。
- n=7,k=1:
- 第一小时内,我们将更新文件从计算机 1 复制到计算机 2;
- 第二小时内,我们将更新文件从计算机 1 复制到计算机 3;
- 第三小时内,我们将更新文件从计算机 1 复制到计算机 4;
- 第四小时内,我们将更新文件从计算机 4 复制到计算机 5;
- 第五小时内,我们将更新文件从计算机 4 复制到计算机 6;
- 第六小时内,我们将更新文件从计算机 3 复制到计算机 7。
输入解题思路,AI测评打分。不知道怎么写?