#abc319c. C - False Hope
C - False Hope
Score : points
问题描述
存在一个 的网格,其中每个格子中填有从1到9(包括1和9)的数字。位于第行(从上数)和第列(从左数)的格子 中包含数字 。
同一个数字可能出现在不同的格子中,但不会在垂直、水平或对角线上连续的三个格子中出现。更具体地讲,保证满足以下所有条件:
- 对于任意 ,不成立 。
- 对于任意 ,不成立 。
- 不成立 。
- 不成立 。
高桥将按照随机顺序查看每个格子中的数字。当存在一条(垂直、水平或对角线)满足以下条件时,他会感到 失望:
- 他首先看到的两个格子中的数字相同,但最后一个格子中的数字不同。
请计算高桥在不感到失望的情况下查看所有格子中数字的概率。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with numbers between and , inclusive, written in each square. The square at the -th row from the top and -th column from the left contains the number .
The same number may be written in different squares, but not in three consecutive cells vertically, horizontally, or diagonally. More precisely, it is guaranteed that satisfies all of the following conditions.
- does not hold for any .
- does not hold for any .
- does not hold.
- does not hold.
Takahashi will see the numbers written in each cell in random order. He will get disappointed when there is a line (vertical, horizontal, or diagonal) that satisfies the following condition.
- The first two squares he sees contain the same number, but the last square contains a different number.
Find the probability that Takahashi sees the numbers in all the squares without getting disappointed.
Constraints
- $c _ {i,j}\in\lbrace1,2,3,4,5,6,7,8,9\rbrace\ (1\leq i\leq3,1\leq j\leq3)$
- does not hold for any .
- does not hold for any .
- does not hold.
- does not hold.
Input
The input is given from Standard Input in the following format:
Output
Print one line containing the probability that Takahashi sees the numbers in all the squares without getting disappointed. Your answer will be considered correct if the absolute error from the true value is at most .
Sample Input 1
3 1 9
2 5 6
2 7 1
Sample Output 1
0.666666666666666666666666666667
For example, if Takahashi sees in this order, he will get disappointed.
On the other hand, if Takahashi sees $c _ {1,1},c _ {1,2},c _ {1,3},c _ {2,1},c _ {2,2},c _ {2,3},c _ {3,1},c _ {3,2},c _ {3,3}$ in this order, he will see all numbers without getting disappointed.
The probability that Takahashi sees all the numbers without getting disappointed is . Your answer will be considered correct if the absolute error from the true value is at most , so outputs such as and would also be accepted.
Sample Input 2
7 7 6
8 6 8
7 7 6
Sample Output 2
0.004982363315696649029982363316
Sample Input 3
3 6 7
1 9 7
5 7 5
Sample Output 3
0.4
update @ 2024/3/10 09:07:02