#7582. [USACO26JAN2] Cow Circle P
[USACO26JAN2] Cow Circle P
[USACO26JAN2] Cow Circle P
题目描述
**Note: The time limit for this problem is 6s, thrice the default. The memory limit for this problem is 512MB, twice the default.**Farmer John has () cows standing around a circular track divided into () equally spaced positions, numbered to clockwise. Cow is initially at position , where .
For each , cow will independently and randomly choose either to face clockwise or counterclockwise with some probability specific to that cow. Once a cow has chosen her initial direction, she begins moving continuously in that direction at a constant speed of one position per minute. Whenever two cows meet (i.e., they occupy the same space), they bounce off of each other: immediately reversing their directions and continuing to move at the same speed in that direction.
Farmer John is wondering where cow will end up. For each , find the probability that cow is at position after () minutes.
输入格式
The first line contains $T$ ($1 \leq T \leq 100$), the number of independent test cases. Each test case is specified as follows:- The first line of each test case contains (), (), and ().
- The second line contains integers () where if is the probability cow goes clockwise, then .
- The third and final line contains integers .
It is guaranteed that the sum of over all test cases is and the sum of over all testcases is .
输出格式
Output a new line for each test case. The line for each test case should be formatted as follows: - For every $0 \leq i3
2 2 1
500000004 500000004
0 1
3 3 1
500000004 500000004 500000004
0 1 2
5 10 13
500000004 1 500000004 0 500000004
0 3 4 7 9
500000004 500000004
500000004 250000002 250000002
0 0 0 125000001 375000003 0 125000001 375000003 0 0
提示
For the first test case, both cows have a $\frac{1}{2}$ chance of going in either direction. If both pick the same direction, they will end up swapping positions (so cow $1$ ends up at $1$). Otherwise, they will bounce off in the middle and return to their original positions. Therefore, there is a $\frac{1}{2}$ chance for cow $1$ to end up at $0$ and a $\frac{1}{2}$ chance for cow $1$ to end up at $1$.For the second test case, all cows again have a chance of going in either direction. For each combination of directions, here is where cow ends up at.
- CW, CW, CW:
- CW, CW, CCW:
- CCW, CCW, CCW:
- CCW, CW, CCW:
- CW, CCW, CW:
- CW, CCW, CCW:
- CCW, CW, CW:
- CCW, CCW, CW:
SCORING:
- Input 2: .
- Input 3: .
- Inputs 4-7: .
- Inputs 8-11: .
- Inputs 12-15: No additional constraints. 标签: P15264|USACO|2026