A14760 | Update Files
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 10^5$ ) — the number of test cases.
Each test case consists of a single line that contains two integers $n$ and $k$ ( $1 \le k \le n \le 10^{18}$ ) — the number of computers and the number of patch cables.
Each test case consists of a single line that contains two integers $n$ and $k$ ( $1 \le k \le n \le 10^{18}$ ) — the number of computers and the number of patch cables.
输出格式
For each test case print one integer — the minimum number of hours required to copy the update files to all $n$ computers.
输入输出样例
输入 #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$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
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$ ;
3. 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$ ;
4. during the fourth hour, we copy the update files from the computer $2$ to the computer $8$ .
- $n=6$ , $k=6$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
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$ ;
3. 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$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
2. during the second hour, we copy the update files from the computer $1$ to the computer $3$ ;
3. during the third hour, we copy the update files from the computer $1$ to the computer $4$ ;
4. during the fourth hour, we copy the update files from the computer $4$ to the computer $5$ ;
5. during the fifth hour, we copy the update files from the computer $4$ to the computer $6$ ;
6. during the sixth hour, we copy the update files from the computer $3$ to the computer $7$ .
- $n=8$ , $k=3$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
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$ ;
3. 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$ ;
4. during the fourth hour, we copy the update files from the computer $2$ to the computer $8$ .
- $n=6$ , $k=6$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
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$ ;
3. 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$ :
1. during the first hour, we copy the update files from the computer $1$ to the computer $2$ ;
2. during the second hour, we copy the update files from the computer $1$ to the computer $3$ ;
3. during the third hour, we copy the update files from the computer $1$ to the computer $4$ ;
4. during the fourth hour, we copy the update files from the computer $4$ to the computer $5$ ;
5. during the fifth hour, we copy the update files from the computer $4$ to the computer $6$ ;
6. during the sixth hour, we copy the update files from the computer $3$ to the computer $7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted