CF1717D.Madoka and The Corruption Scheme
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
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 2n participants in the tournament, numbered with integers from 1 to 2n. There are n rounds in total in the tournament. In the i-th round there are 2n−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).
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 109+7. Note that we need to minimize the answer, and only then take it modulo.
魔理沙决定承办一场大型电脑游戏锦标赛“OSU”!
本次锦标赛采用“奥林匹克赛制”。也就是说,锦标赛共有 2n 名参赛者,编号为 1 到 2n 的整数。锦标赛共进行 n 轮。在第 i 轮中,共进行 2n−i 场比赛,每场比赛由两名选手(一名在左、一名在右)对决;胜者继续留在锦标赛对阵表中晋级下一轮,败者则被淘汰。此外,晋级选手在下一轮中的相对顺序保持不变。锦标赛的最终获胜者即为最后唯一剩下的选手。
但编号越小的选手,若最终夺冠,则付给魔理沙的奖金越多,因此魔理沙希望编号最小的选手赢得冠军。为此,她可以自由安排第一轮中所有选手的初始顺序,并且对每场比赛,她都可以指定哪一方(左侧或右侧选手)获胜。
然而,魔理沙知道:锦标赛赞助商最多可将 k 场比赛的胜负结果进行翻转(即:若原先左侧选手获胜,则翻转后变为右侧选手获胜;若原先右侧选手获胜,则翻转后变为左侧选手获胜)。
因此,第一张图展示了魔理沙所设计的锦标赛对阵表,其中红色连线表示每场比赛本应获胜的选手。第二张图则展示赞助商对其中一场比赛(选手 1 与选手 3 之间的比赛)的胜负结果进行一次翻转后的对阵表。
请输出:无论赞助商如何进行至多 k 次胜负翻转,魔理沙都能确保的冠军编号的最小可能值。但由于答案可能非常大,请将该最小值对 109+7 取模后输出。注意:需先求出最小可能的编号,再对该编号取模。
输入格式
The first and the only line contains two integers n and k (1≤n≤105,1≤k≤min(2n−1,109)) — the number of rounds in the tournament and the number of outcomes that sponsors can change.
第一行且唯一一行包含两个整数 n 和 k(1≤n≤105,1≤k≤min(2n−1,109))——分别表示锦标赛的轮数以及赞助商可以更改的结果数量。
输出格式
Print exactly one integer — the minimum number of the winner modulo 109+7
输出一个整数——获胜者的最小编号对 109+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 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.
在第一个例子中,选手 1 和 2 之间仅有一场比赛,因此赞助商总能让选手 2 获胜。
第二个例子中的锦标赛对阵图如题面图片所示。
输入解题思路,AI测评打分。不知道怎么写?