308803: CF1578E. Easy Scheduling
Memory Limit:1024 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Easy Scheduling
题意翻译
一棵 $h$ 层满二叉树,想要消去它。只有暴露的节点可以被消去,而且一次最多消去 $q$ 个暴露的节点。 最开始只有根节点是暴露的节点。但是,如果消去了一个节点,它的子节点就会暴露出来。那么最少几次消去整棵树?题目描述
Eonathan Eostar decided to learn the magic of multiprocessor systems. He has a full binary tree of tasks with height $ h $ . In the beginning, there is only one ready task in the tree — the task in the root. At each moment of time, $ p $ processes choose at most $ p $ ready tasks and perform them. After that, tasks whose parents were performed become ready for the next moment of time. Once the task becomes ready, it stays ready until it is performed. You shall calculate the smallest number of time moments the system needs to perform all the tasks.输入输出格式
输入格式
The first line of the input contains the number of tests $ t $ ( $ 1 \leq t \leq 5\cdot 10^5 $ ). Each of the next $ t $ lines contains the description of a test. A test is described by two integers $ h $ ( $ 1 \leq h \leq 50 $ ) and $ p $ ( $ 1 \leq p \leq 10^4 $ ) — the height of the full binary tree and the number of processes. It is guaranteed that all the tests are different.
输出格式
For each test output one integer on a separate line — the smallest number of time moments the system needs to perform all the tasks.
输入输出样例
输入样例 #1
3
3 1
3 2
10 6
输出样例 #1
7
4
173