CF815E.Karen and Neighborhood

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

It's been long after the events of the previous problems, and Karen has now moved on from student life and is looking to relocate to a new neighborhood.

The neighborhood consists of n houses in a straight line, labelled 1 to n from left to right, all an equal distance apart.

Everyone in this neighborhood loves peace and quiet. Because of this, whenever a new person moves into the neighborhood, he or she always chooses the house whose minimum distance to any occupied house is maximized. If there are multiple houses with the maximum possible minimum distance, he or she chooses the leftmost one.

Note that the first person to arrive always moves into house 1.

Karen is the k-th person to enter this neighborhood. If everyone, including herself, follows this rule, which house will she move into?

距离上一道题的事件已经过去很久,凯伦(Karen)早已告别学生时代,正计划搬入一个新社区。

该社区由一条直线上排列的 nn 座房屋组成,从左至右依次编号为 11 到 nn,且相邻房屋间距相等。

社区中的每个人都热爱宁静与安逸。因此,每当有新人搬入时,他或她总会选择到任意已入住房屋的最小距离最大的那座房屋;若存在多个房屋具有相同的最大最小距离,则选择其中最靠左的一座。

注意:第一位到来的人总是入住第 11 号房屋。

凯伦是第 kk 位搬入该社区的人。若包括她在内,所有人都严格遵循上述规则,那么她将入住哪一座房屋?

输入格式

The first and only line of input contains two integers, n and k (1 ≤ k ≤ n ≤ 1018), describing the number of houses in the neighborhood, and that Karen was the k-th person to move in, respectively.

输入仅有一行,包含两个整数 nn 和 kk(1 ≤ k ≤ n ≤ 10181 ≤ k ≤ n ≤ 10^{18}),分别表示社区中的房屋总数,以及凯伦是第 kk 个搬入的人。

输出格式

Output a single integer on a line by itself, the label of the house Karen will move into.

在单独一行中输出一个整数,即凯伦将搬入的房子的编号。

输入输出样例

  • 输入#1

    6 4

    输出#1

    2
  • 输入#2

    39 3

    输出#2

    20

说明/提示

In the first test case, there are 6 houses in the neighborhood, and Karen is the fourth person to move in:

  1. The first person moves into house 1.
  2. The second person moves into house 6.
  3. The third person moves into house 3.
  4. The fourth person moves into house 2.

In the second test case, there are 39 houses in the neighborhood, and Karen is the third person to move in:

  1. The first person moves into house 1.
  2. The second person moves into house 39.
  3. The third person moves into house 20.

在第一个测试用例中,社区共有 6 座房屋,Karen 是第四个搬入的人:

  1. 第一个人搬入第 1 号房屋。
  2. 第二个人搬入第 6 号房屋。
  3. 第三个人搬入第 3 号房屋。
  4. 第四个人搬入第 2 号房屋。

在第二个测试用例中,社区共有 39 座房屋,Karen 是第三个搬入的人:

  1. 第一个人搬入第 1 号房屋。
  2. 第二个人搬入第 39 号房屋。
  3. 第三个人搬入第 20 号房屋。

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

首页