QOJ.ac

QOJ

Limite de temps : 8 s Limite de mémoire : 256 MB Points totaux : 100

#8702. Werewolf

Statistiques

Werewolf is a classic social deduction board game. In a game of Werewolf, each player is assigned a role such as "Villager," "Werewolf," or "Seer." Werewolves must hide their identity, the Seer can check a player's identity at night, and the Villagers must work under the guidance of the Seer to identify the Werewolf.

Today, Kanan and her friends are playing a game with $n$ players. In this game, players are numbered from $1$ to $n$, and Kanan's number is $m$.

Unlike the traditional version, this game includes one Werewolf, one Seer, and $n-2$ Villagers. Every night, only the Seer can take action (the Werewolf cannot kill anyone): the player acting as the Seer chooses an interval of player numbers $[l, r]$, and they are informed whether the Werewolf's number is within this interval.

Kanan is assigned the role of the Werewolf, and she wants to estimate the difficulty of hiding her identity. Assume that each of Kanan's friends has an equal probability of being the Seer (each friend has a probability of $\frac{1}{n-1}$), and each night, the Seer chooses an interval to check uniformly at random from all possible intervals (each interval has a probability of $\frac{2}{n(n+1)}$). Kanan wants to know the expected number of nights after which the information obtained by the Seer uniquely identifies Kanan as the Werewolf.

Input

The input contains two integers $n, m$ ($2 \leq n \leq 150, 1 \leq m \leq n$), representing the total number of players and Kanan's number.

Note: The code length limit for this problem is 8kB.

Output

Output a single integer representing the answer modulo $1,000,000,007$. In other words, if the answer is expressed as an irreducible fraction $x/y$, you should output the value of $x \times y^{1,000,000,005} \pmod{1,000,000,007}$.

Examples

Input 1

2 2

Output 1

0

Input 2

3 2

Output 2

2

Input 3

3 3

Output 3

750000007

Input 4

10 5

Output 4

470594541

Note

In the first test case, there are only two players, so the Seer knows the other player (Kanan) is the Werewolf without needing to use their ability.

In the second test case, assume the Seer's number is 1 (the other case is symmetric). The Seer can uniquely identify the Werewolf only if they ask about $[1, 2]$, $[2, 2]$, or $[3, 3]$. Therefore, the probability that the Seer identifies Kanan for the first time after $i$ nights is $(1/2)^i$. Thus, the answer is $\sum_{i=1}^{+\infty} (1/2)^i \cdot i = 2$.

In the third test case, there are two scenarios depending on the Seer's number:

  • If the Seer's number is 1, they can uniquely identify the Werewolf only if they ask about $[1, 2]$, $[2, 2]$, or $[3, 3]$. The expected number of nights required is 2.
  • If the Seer's number is 2, they can uniquely identify the Werewolf only if they ask about $[1, 1]$, $[1, 2]$, $[2, 3]$, or $[3, 3]$. The expected number of nights required is $3/2$.

Combining both scenarios, the answer is $(2 + (3/2))/2 = 7/4$.

Subtasks

Subtask 1 (23 points), $1 \leq n \leq 20$.

Subtask 2 (34 points), $1 \leq n \leq 50$.

Subtask 3 (43 points), $1 \leq n \leq 150$.

Note: The code length limit for this problem is 8kB.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.