Codeforces Round 818 (Div. 2)
D
Madoka and The Corruption Scheme
Codeforces
1900
原题
← CE →
翻译中…

Madoka decided to entrust the organization of a major computer game tournament "OSU"!

翻译中…

In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the $i$-th round there are $2^{n - i}$ matches between two players (one of whom is right, the other is left), after which the winners go further along the tournament grid, and the losing participants are eliminated from the tournament. Herewith, the relative order in the next round does not change. And the winner of the tournament — is the last remaining participant.

翻译中…

But the smaller the participant's number, the more he will pay Madoka if he wins, so Madoka wants the participant with the lowest number to win. To do this, she can arrange the participants in the first round as she likes, and also determine for each match who will win — the participant on the left or right.

翻译中…

But Madoka knows that tournament sponsors can change the winner in matches no more than $k$ times. (That is, if the participant on the left won before the change, then the participant on the right will win after the change, and if the participant on the right won, then the participant on the left will win after the change).

翻译中…

image So, the first image shows the tournament grid that Madoka made, where the red lines denote who should win the match. And the second one shows the tournament grid, after one change in the outcome of the match by sponsors (a match between $1$ and $3$ players).

翻译中…

Print the minimum possible number of the winner in the tournament, which Madoka can get regardless of changes in sponsors. But since the answer can be very large, output it modulo $10^9 + 7$. Note that we need to minimize the answer, and only then take it modulo.

翻译中…

Input

翻译中…

The first and the only line contains two integers $n$ and $k$ ($1 \le n \le 10^5, 1 \le k \le \min(2^n - 1, 10^9)$) — the number of rounds in the tournament and the number of outcomes that sponsors can change.

翻译中…

Output

翻译中…

Print exactly one integer — the minimum number of the winner modulo $10^9 + 7$

翻译中…

Note

翻译中…

In the first example, there is only one match between players $1$ and $2$, so the sponsors can always make player $2$ wins.

翻译中…

The tournament grid from the second example is shown in the picture in the statement.

翻译中…

样例

Input #1
1 1
Output #1
2
InputCopy OutputCopy
Input #2
2 1
Output #2
3
InputCopy OutputCopy
Input #3
3 2
Output #3
7
InputCopy OutputCopy
题目信息
题号
1717D
时间限制
1 s
内存限制
256 MB
标签
组合数学
构造
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。