CF201E.Thoroughly Bureaucratic Organization

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater for exactly one person per day. As a consequence, each of n people made an appointment on one of the next n days, and no two persons have an appointment on the same day.

However, the organization workers are very irresponsible about their job, so none of the signed in people was told the exact date of the appointment. The only way to know when people should come is to write some requests to TBO.

The request form consists of m empty lines. Into each of these lines the name of a signed in person can be written (it can be left blank as well). Writing a person's name in the same form twice is forbidden, such requests are ignored. TBO responds very quickly to written requests, but the reply format is of very poor quality — that is, the response contains the correct appointment dates for all people from the request form, but the dates are in completely random order. Responds to all requests arrive simultaneously at the end of the day (each response specifies the request that it answers).

Fortunately, you aren't among these n lucky guys. As an observer, you have the following task — given n and m, determine the minimum number of requests to submit to TBO to clearly determine the appointment date for each person.

有 nn 人同时在一家新近成立、但已高度官僚化的组织(简称 TBO)前台完成登记。由于该组织高度官僚化,它每天恰好只能接待并服务一人。因此,这 nn 人均预约了接下来 nn 天中的某一天,且任意两人预约的日期互不相同。

然而,TBO 的工作人员对其工作极不负责,以至于没有任何一位已完成登记的人被告知其确切的预约日期。人们唯一获知自己应到访日期的方式,是向 TBO 提交若干请求。

每份请求表格包含 mm 个空白行。在每一行中,可填写一位已登记人员的姓名(也可留空)。同一份请求表中不得重复填写同一人的姓名;若出现重复,该请求将被忽略。TBO 对书面请求响应极为迅速,但其回复格式质量极差——即:回复中会准确列出请求表中所有人员的预约日期,但这些日期以完全随机的顺序呈现。所有请求的回复均于当日结束时同时送达(每份回复均明确标注其所对应的请求)。

幸运的是,你并不在这 nn 位“幸运儿”之中。作为旁观者,你的任务是:给定 nn 和 mm,确定为明确判定每位人员的预约日期,所需提交给 TBO 的最少请求数量。

输入格式

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Each of the following t lines contains two integers n and m (1 ≤ n, m ≤ 109) — the number of people who have got an appointment at TBO and the number of empty lines in the request form, correspondingly.

第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000)—— 测试用例的数量。接下来的 tt 行中,每行包含两个整数 nn 和 mm(1≤n,m≤1091 \leq n, m \leq 10^9)—— 分别表示在 TBO 预约的人数以及申请表中的空行数。

输出格式

Print t lines, each containing an answer for the corresponding test case (in the order they are given in the input) — the minimum number of requests to submit to TBO.

输出 t 行,每行包含一个对应测试用例的答案(按输入中给出的顺序)——即提交给 TBO 的最少请求数。

输入输出样例

  • 输入#1

    5
    4 1
    4 2
    7 3
    1 1
    42 7

    输出#1

    3
    2
    3
    0
    11

说明/提示

In the first sample, you need to submit three requests to TBO with three different names. When you learn the appointment dates of three people out of four, you can find out the fourth person's date by elimination, so you do not need a fourth request.

In the second sample you need only two requests. Let's number the persons from 1 to 4 and mention persons 1 and 2 in the first request and persons 1 and 3 in the second request. It is easy to see that after that we can clearly determine each person's appointment date regardless of the answers obtained from TBO.

In the fourth sample only one person signed up for an appointment. He doesn't need to submit any requests — his appointment date is tomorrow.

在第一个样例中,你需要向TBO提交三份请求,每份请求使用三个不同的姓名。当你得知四人中三人的预约日期后,即可通过排除法推断出第四人的预约日期,因此无需提交第四份请求。

在第二个样例中,你仅需提交两份请求。我们将四人编号为1至4,并在第一份请求中提及第1号和第2号人员,在第二份请求中提及第1号和第3号人员。容易看出,无论从TBO获得何种答复,我们均能据此明确判定每位人员的预约日期。

在第四个样例中,仅有一人预约了服务。他无需提交任何请求——他的预约日期即为明天。

输入解题思路,AI测评打分。不知道怎么写?

首页