CF815E.Karen and Neighborhood

普及/提高-

通过率:0%

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 nn houses in a straight line, labelled 11 to nn 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 11 .

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

输入格式

The first and only line of input contains two integers, nn and kk ( 1<=k<=n<=10181<=k<=n<=10^{18} ), describing the number of houses in the neighborhood, and that Karen was the kk -th person to move in, respectively.

输出格式

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 66 houses in the neighborhood, and Karen is the fourth person to move in:

  1. The first person moves into house 11 .
  2. The second person moves into house 66 .
  3. The third person moves into house 33 .
  4. The fourth person moves into house 22 .

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

  1. The first person moves into house 11 .
  2. The second person moves into house 3939 .
  3. The third person moves into house 2020 .
首页