304276: CF815E. Karen and Neighborhood

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Karen and Neighborhood

题意翻译

$Karen$要住进新房子。这一条街上有$n$栋房子,编号为$1$~$n$。在$Karen$之前有$k-1$个人住进这条街,即$Karen$是第$k$个搬进这条街的人。每个人住进这条街都有一个选房子的法则:如果他选的房子与离这栋房子最近的一栋房子的距离最大,那么就选这栋房子;如果有多栋房子满足前面一条规则,就选择最靠左的房子(这样的话,第$1$个人选的是$1$号房)。请问$Karen$选的房子是几号房子? ### 输入: 一行两个整数$n$和$k$。 ### 输出: 一个整数为$Karen$选的房子。 ### 数据范围: $1<=k<=n<=10^{18}$

题目描述

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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF815E/8bd2a5609d0d80a04305caa2f81f70648ac35159.png)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?

输入输出格式

输入格式


The first and only line of input contains two integers, $ n $ and $ k $ ( $ 1<=k<=n<=10^{18} $ ), describing the number of houses in the neighborhood, and that Karen was the $ k $ -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 $ 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 $ .

Input

题意翻译

$Karen$要住进新房子。这一条街上有$n$栋房子,编号为$1$~$n$。在$Karen$之前有$k-1$个人住进这条街,即$Karen$是第$k$个搬进这条街的人。每个人住进这条街都有一个选房子的法则:如果他选的房子与离这栋房子最近的一栋房子的距离最大,那么就选这栋房子;如果有多栋房子满足前面一条规则,就选择最靠左的房子(这样的话,第$1$个人选的是$1$号房)。请问$Karen$选的房子是几号房子? ### 输入: 一行两个整数$n$和$k$。 ### 输出: 一个整数为$Karen$选的房子。 ### 数据范围: $1<=k<=n<=10^{18}$

加入题单

算法标签: