Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"William is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i . Each two teams i < j play with each other exactly once. Team i wins with probability frac{a_i}{a_i + a_j} and team j wins with probability frac{a_j}{a_i + a_j} . The team is called a winner if it directly or indirectly defeated all other teams. Team a defeated (directly or indirectly) team b if there is a sequence of teams c_1 , c_2 , ... c_k such that c_1 = a , c_k = b and team c_i defeated team c_{i + 1} for all i from 1 to k - 1 . Note that it is possible that team a defeated team b and in the same time team b defeated team a . William wants you to find the expected value of the number of winners. The first line contains a single integer n ( 1 <= q n <= q 14 ), which is the total number of teams participating in a match. The second line contains n integers a_1, a_2, ... , a_n ( 1 <= q a_i <= q 10^6 ) -- the strengths of teams participating in a match. Output a single integer -- the expected value of the number of winners of the tournament modulo 10^9 + 7 . Formally, let M = 10^9+7 . It can be demonstrated that the answer can be presented as a irreducible fraction frac{p}{q} , where p and q are integers and q not equiv 0 pmod{M} . Output a single integer equal to p cdot q^{-1} bmod M . In other words, output an integer x such that 0 <= x < M and x cdot q equiv p pmod{M} . To better understand in which situation several winners are possible let's examine the second test: One possible result of the tournament is as follows ( a rightarrow b means that a defeated b ): Or more clearly in the picture: In this case every team from the set { 1, 2, 3 } di"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
127390329 |
soltanbh |
F |
Aug. 29, 2021, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
155 |
6246400 |
|
2500 |
127410441 |
lgzhy12138 |
F |
Aug. 30, 2021, 2:16 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
187 |
8704000 |
|
2500 |
127383713 |
chitanda |
F |
Aug. 29, 2021, 4:39 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
405 |
5632000 |
|
2500 |
127382851 |
dai |
F |
Aug. 29, 2021, 4:36 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
452 |
5222400 |
|
2500 |
127386684 |
axs7384 |
F |
Aug. 29, 2021, 4:50 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
467 |
4915200 |
|
2500 |
127416720 |
rfpermen |
F |
Aug. 30, 2021, 4:48 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
467 |
7782400 |
|
2500 |
127383848 |
happyguy656 |
F |
Aug. 29, 2021, 4:40 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
483 |
5939200 |
|
2500 |
127380646 |
LIKE0314 |
F |
Aug. 29, 2021, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
498 |
3891200 |
|
2500 |
127415635 |
Potassium_ |
F |
Aug. 30, 2021, 4:24 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
499 |
4812800 |
|
2500 |
127384094 |
PaiGuLong |
F |
Aug. 29, 2021, 4:40 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
529 |
11878400 |
|
2500 |
127397068 |
Koosha_Mv |
F |
Aug. 29, 2021, 6:37 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
140 |
6246400 |
|
2500 |
127408312 |
evean |
F |
Aug. 30, 2021, 1:02 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
155 |
4812800 |
|
2500 |
127401914 |
WeakestTopology |
F |
Aug. 29, 2021, 8:23 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
218 |
8192000 |
|
2500 |
127416500 |
2919805063 |
F |
Aug. 30, 2021, 4:44 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
264 |
5427200 |
|
2500 |
127404790 |
EmanuelDicu |
F |
Aug. 29, 2021, 10:02 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
296 |
4812800 |
|
2500 |
127410479 |
cs142857 |
F |
Aug. 30, 2021, 2:18 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
343 |
4710400 |
|
2500 |
127412934 |
anthony.y.wang.math |
F |
Aug. 30, 2021, 3:22 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
405 |
4812800 |
|
2500 |
127384402 |
knightL |
F |
Aug. 29, 2021, 4:42 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
405 |
5734400 |
|
2500 |
127389406 |
darkkcyan |
F |
Aug. 29, 2021, 4:59 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
405 |
5836800 |
|
2500 |
127398446 |
flashmt |
F |
Aug. 29, 2021, 7:01 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
421 |
4812800 |
|
2500 |
127380003 |
Xellos |
F |
Aug. 29, 2021, 4:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
62 |
6758400 |
|
2500 |
127401755 |
WeakestTopology |
F |
Aug. 29, 2021, 8:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
78 |
8601600 |
|
2500 |
127391014 |
l1ll5 |
F |
Aug. 29, 2021, 5:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
108 |
5529600 |
|
2500 |
127404820 |
JovanB |
F |
Aug. 29, 2021, 10:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
217 |
5632000 |
|
2500 |
127396743 |
6aren |
F |
Aug. 29, 2021, 6:32 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
233 |
5427200 |
|
2500 |
127398212 |
Denisson |
F |
Aug. 29, 2021, 6:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
234 |
5324800 |
|
2500 |
127384118 |
dengyaotriangle |
F |
Aug. 29, 2021, 4:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
234 |
5324800 |
|
2500 |
127381598 |
dario2994 |
F |
Aug. 29, 2021, 4:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
249 |
4403200 |
|
2500 |
127393993 |
kimoyami |
F |
Aug. 29, 2021, 6:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
249 |
5324800 |
|
2500 |
127396617 |
Takagi |
F |
Aug. 29, 2021, 6:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
249 |
6451200 |
|
2500 |
127382221 |
dalt |
F |
Aug. 29, 2021, 4:34 p.m. |
OK |
Java 11 |
TESTS |
27 |
374 |
24985600 |
|
2500 |
127383673 |
darnley |
F |
Aug. 29, 2021, 4:39 p.m. |
OK |
Kotlin |
TESTS |
27 |
3681 |
21708800 |
|
2500 |
127382875 |
sansen |
F |
Aug. 29, 2021, 4:36 p.m. |
OK |
Rust |
TESTS |
27 |
2776 |
3891200 |
|
2500 |
remove filters
Back to search problems