CF1717D.Madoka and The Corruption Scheme

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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 2n2^n participants in the tournament, numbered with integers from 11 to 2n2^n . There are nn rounds in total in the tournament. In the ii -th round there are 2ni2^{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 kk 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).

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 11 and 33 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 109+710^9 + 7 . Note that we need to minimize the answer, and only then take it modulo.

输入格式

The first and the only line contains two integers nn and kk ( 1n105,1kmin(2n1,109)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.

输出格式

Print exactly one integer — the minimum number of the winner modulo 109+710^9 + 7

输入输出样例

  • 输入#1

    1 1

    输出#1

    2
  • 输入#2

    2 1

    输出#2

    3
  • 输入#3

    3 2

    输出#3

    7

说明/提示

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

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

首页