#abc289h. Ex - Trio
Ex - Trio
Score : points
问题陈述
在数轴上有三个人:第1个人、第2个人和第3个人。初始时刻(时间),第1个人位于点,第2个人位于点,第3个人位于点。其中,、和均为整数,并且满足。
在时间时,这三个人开始随机漫步。具体来说,在某一时刻(为非负整数)位于点的人,在时刻时以相同的概率移动到点或点。(所有移动的选择都是随机且相互独立的。)
求在时间时,三人首次同时到达同一位置的概率对取模的结果。
什么是模下的有理数?我们可以证明所求概率始终是一个有理数。而且,在本题的约束条件下,当该值表示为两个互质整数和的比值时,可以证明存在一个唯一的整数,使得且。请找出这样的。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
On a number line are person , person , and person . At time , person is at point , person is at point , and person is at point .
Here, , , and are all integers, and .
At time , the three people start random walks. Specifically, a person that is at point at time ( is a non-negative integer) moves to point or point at time with equal probability. (All choices of moves are random and independent.)
Find the probability, modulo , that it is at time that the three people are at the same point for the first time.
What is rational number modulo ? We can prove that the sought probability is always a rational number. Moreover, under the Constraints of this problem, when the value is represented as by two coprime integers and , we can prove that there is a unique integer such that and . Find such .
Constraints
- , and are integers.
Input
The input is given from Standard Input in the following format:
Output
Find the probability, modulo , that it is at time that the three people are at the same point for the first time, and print the answer.
Sample Input 1
1 1 3 1
Sample Output 1
873463809
The three people are at the same point for the first time at time with the probability . Since , should be printed.
Sample Input 2
0 0 0 0
Sample Output 2
1
The three people may already be at the same point at time .
Sample Input 3
0 2 8 9
Sample Output 3
744570476
Sample Input 4
47717 21993 74147 76720
Sample Output 4
844927176
update @ 2024/3/10 12:06:03