Anticipating calculations utilized in VK have effectively assessed the likelihood for every occasion to occur. Occasion in line I and section j will occur with likelihood ai,j⋅10−4. Every one of the occasions are autonomous together.
Correct answer will be upvoted else downvoted. Code and output screenshot.
Anticipating calculations utilized in VK have effectively assessed the likelihood for every occasion to occur. Occasion in line I and section j will occur with likelihood
How about we call the table winning if there exists a line to such an extent that all n occasions on it occur. The line could be any flat line (cells (i,1),(i,2),… ,(i,n) for some I), any upward line (cells (1,j),(2,j),… ,(n,j) for some j), the fundamental corner to corner (cells (1,1),(2,2),… ,(n,n)), or the antidiagonal (cells (1,n),(2,n−1),… ,(n,1)).
View the likelihood of your table to be winning, and output it modulo 31607 (see Output area).
Input
The primary line contains a solitary integer n (2≤n≤21) — the elements of the table.
The I-th of the following n lines contains n integers ai,1,ai,2,… ,ai,n (0<ai,j<104). The likelihood of occasion in cell (i,j) to happen is ai,j⋅10−4.
Output
Print the likelihood that your table will be winning, modulo 31607.
Officially, let M=31607. It tends to be shown that the appropriate response can be communicated as an unchangeable division pq, where p and q are integers and q≢0(modM). Output the integer equivalent to p⋅q−1modM. At the end of the day, output such an integer x that 0≤x<M and x⋅q≡p(modM).
Step by step
Solved in 3 steps with 1 images