#abc306h. Ex - Balance Scale
Ex - Balance Scale
Score : points
问题描述
有 个编号为 的砝码。
我们将使用天平进行 次砝码比较。
- 在进行比较之前,准备一个空字符串 。
- 对于第 次比较,仅将砝码 放在左侧碗中,将砝码 放在右侧碗中。
- 然后,会得到以下三种结果之一:
- 如果砝码 比砝码 重,
- 将
>
追加到字符串 的末尾。
- 将
- 如果砝码 和砝码 质量相同,
- 将
=
追加到字符串 的末尾。
- 将
- 如果砝码 比砝码 轻,
- 将
<
追加到字符串 的末尾。
- 将
- 如果砝码 比砝码 重,
- 结果总是准确的。
实验结束后,你会得到一个长度为 的字符串 。
在由 >
, =
, <
组成的长度为 的所有 个字符串中,有多少个可以通过该实验获得作为 ?
由于答案可能非常大,请输出答案对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are weights numbered .
Using a balance, we will compare weights times.
- Before the comparisons, prepare an empty string .
- For the -th comparison, put just weight to the left bowl, and just weight to the right.
- Then, one of the following three results is obtained.
- If weight is heavier than weight ,
- append
>
to the tail of .
- append
- If weight and weight have the same mass,
- append
=
to the tail of .
- append
- If weight is lighter than weight ,
- append
<
to the tail of .
- append
- If weight is heavier than weight ,
- The result is always accurate.
After the experiment, you will obtain a string of length .
Among the strings of length consisting of >
, =
, and <
, how many can be obtained as by the experiment?
Since the answer can be enormous, print the answer modulo .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 3
1 2
1 3
2 3
Sample Output 1
13
Let be the sequence of the mass of the weights, in ascending order of weight numbers.
- If , you obtain
===
. - If , you obtain
=<<
. - If , you obtain
<=>
. - If , you obtain
>>=
. - If , you obtain
=>>
. - If , you obtain
>=<
. - If , you obtain
<<=
. - If , you obtain
<<<
. - If , you obtain
<<>
. - If , you obtain
><<
. - If , you obtain
<>>
. - If , you obtain
>><
. - If , you obtain
>>>
.
While there is an infinite number of possible sequences of the mass of the weights, is always one of the above.
Sample Input 2
4 4
1 4
2 3
1 3
3 4
Sample Output 2
39
Sample Input 3
14 15
1 2
1 3
2 4
2 5
2 6
4 8
5 6
6 8
7 8
9 10
9 12
9 13
10 11
11 12
11 13
Sample Output 3
1613763
update @ 2024/3/10 08:40:17