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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 809 | Codeforces Round 415 (Div. 1) | FINISHED | False | 7200 | 281188485 | May 20, 2017, 6:05 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 854 ) | E | Surprise me! | PROGRAMMING | divide and conquer math number theory trees | 3000 |
Tired of boring dates, Leha and Noora decided to play a game. Leha found a tree with n vertices numbered from 1 to n . We remind you that tree is an undirected graph without cycles. Each vertex v of a tree has a number a v written on it. Quite by accident it turned out that all values written on vertices are distinct and are natural numbers between 1 and n . The game goes in the following way. Noora chooses some vertex u of a tree uniformly at random and passes a move to Leha. Leha, in his turn, chooses (also uniformly at random) some vertex v from remaining vertices of a tree ( v ≠ u ) . As you could guess there are n ( n - 1) variants of choosing vertices by players. After that players calculate the value of a function f ( u , v ) = φ( a u · a v ) · d ( u , v ) of the chosen vertices where φ( x ) is Euler's totient function and d ( x , y ) is the shortest distance between vertices x and y in a tree. Soon the game became boring for Noora, so Leha decided to defuse the situation and calculate expected value of function f over all variants of choosing vertices u and v , hoping of at least somehow surprise the girl. Leha asks for your help in calculating this expected value. Let this value be representable in the form of an irreducible fraction . To further surprise Noora, he wants to name her the value . Help Leha! The first line of input contains one integer number n (2 ≤ n ≤ 2·10 5 ) — number of vertices in a tree. The second line contains n different numbers a 1 , a 2 , ..., a n (1 ≤ a i ≤ n ) separated by spaces, denoting the values written on a tree vertices. Each of the next n - 1 lines contains two integer numbers x and y (1 ≤ x , y ≤ n ) , describing the next edge of a tree. It is guaranteed that this set of edges describes a tree. In a single line print a number equal to P · Q - 1 modulo 10 9 + 7 . Euler's totient function φ( n ) is the number of such i that 1 ≤ i ≤ n ,and gcd ( i , n ) = 1 , where gcd ( x , y ) is the greatest common divisor of nu |
| 52099 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 40981454 | ReaLNero1 | E | July 30, 2018, 6 p.m. | OK | GNU C++ | TESTS | 124 | 982 | 61644800 | 3000 | |
| 32347858 | Scut82 | E | Nov. 16, 2017, 5:46 a.m. | OK | GNU C++ | TESTS | 124 | 998 | 61747200 | 3000 | |
| 33977257 | zjo_2001 | E | Jan. 7, 2018, 6:26 a.m. | OK | GNU C++ | TESTS | 124 | 1092 | 29388800 | 3000 | |
| 33977225 | zjo_2001 | E | Jan. 7, 2018, 6:23 a.m. | OK | GNU C++ | TESTS | 124 | 1092 | 29388800 | 3000 | |
| 31449288 | y20070316 | E | Oct. 17, 2017, 1 p.m. | OK | GNU C++ | TESTS | 124 | 1107 | 26828800 | 3000 | |
| 27275992 | hzq84621 | E | May 22, 2017, 2:32 a.m. | OK | GNU C++ | TESTS | 124 | 1122 | 23961600 | 3000 | |
| 27902264 | laofudasuan | E | June 19, 2017, 10:33 a.m. | OK | GNU C++ | TESTS | 124 | 1248 | 54272000 | 3000 | |
| 27904779 | MasterJH5574 | E | June 19, 2017, 12:42 p.m. | OK | GNU C++ | TESTS | 124 | 1294 | 46592000 | 3000 | |
| 40195188 | SovietPower | E | July 11, 2018, 8:47 a.m. | OK | GNU C++ | TESTS | 124 | 1357 | 87552000 | 3000 | |
| 29731127 | Chenhongkan | E | Aug. 24, 2017, 12:36 p.m. | OK | GNU C++ | TESTS | 124 | 1372 | 34304000 | 3000 | |
| 52996816 | liuzhangfeiabc | E | April 19, 2019, 4:31 a.m. | OK | GNU C++11 | TESTS | 124 | 483 | 64819200 | 3000 | |
| 58341544 | luogu_bot3 | E | Aug. 5, 2019, 1:23 p.m. | OK | GNU C++11 | TESTS | 124 | 623 | 51712000 | 3000 | |
| 58326977 | luogu_bot2 | E | Aug. 5, 2019, 8:06 a.m. | OK | GNU C++11 | TESTS | 124 | 685 | 51609600 | 3000 | |
| 58326173 | luogu_bot3 | E | Aug. 5, 2019, 7:50 a.m. | OK | GNU C++11 | TESTS | 124 | 842 | 31232000 | 3000 | |
| 54523502 | Miracle_2001 | E | May 23, 2019, 1:22 p.m. | OK | GNU C++11 | TESTS | 124 | 873 | 109363200 | 3000 | |
| 63361987 | Frame233 | E | Oct. 25, 2019, 6:03 a.m. | OK | GNU C++11 | TESTS | 124 | 889 | 38707200 | 3000 | |
| 58325614 | luogu_bot5 | E | Aug. 5, 2019, 7:38 a.m. | OK | GNU C++11 | TESTS | 124 | 889 | 51609600 | 3000 | |
| 59443479 | PinkRabbit | E | Aug. 25, 2019, 12:17 p.m. | OK | GNU C++11 | TESTS | 124 | 935 | 93184000 | 3000 | |
| 28758786 | geniucos | E | July 21, 2017, 3:23 p.m. | OK | GNU C++11 | TESTS | 124 | 936 | 102195200 | 3000 | |
| 47675568 | lwhlwh | E | Dec. 29, 2018, 8:54 a.m. | OK | GNU C++11 | TESTS | 124 | 951 | 29081600 | 3000 | |
| 42348702 | consecutivelimit | E | Sept. 2, 2018, 2:14 a.m. | OK | GNU C++14 | TESTS | 124 | 623 | 96665600 | 3000 | |
| 57906832 | PinkRabbit | E | July 28, 2019, 5:58 p.m. | OK | GNU C++14 | TESTS | 124 | 1013 | 96460800 | 3000 | |
| 28320636 | NiroBC | E | July 6, 2017, 8:18 a.m. | OK | GNU C++14 | TESTS | 124 | 1107 | 35635200 | 3000 | |
| 57906681 | PinkRabbit | E | July 28, 2019, 5:54 p.m. | OK | GNU C++14 | TESTS | 124 | 1153 | 96460800 | 3000 | |
| 27258597 | data_h | E | May 21, 2017, 4:48 a.m. | OK | GNU C++14 | TESTS | 124 | 1248 | 72089600 | 3000 | |
| 53224027 | Narh | E | April 24, 2019, 1:24 p.m. | OK | GNU C++14 | TESTS | 124 | 1310 | 74547200 | 3000 | |
| 27293102 | WuHongxun | E | May 23, 2017, 2:56 a.m. | OK | GNU C++14 | TESTS | 124 | 1325 | 53760000 | 3000 | |
| 29322736 | whzzt | E | Aug. 10, 2017, 9:30 a.m. | OK | GNU C++14 | TESTS | 124 | 1341 | 45772800 | 3000 | |
| 60905188 | mobu233 | E | Sept. 20, 2019, 1:57 a.m. | OK | GNU C++14 | TESTS | 124 | 1403 | 89088000 | 3000 | |
| 57881969 | BJpers3 | E | July 28, 2019, 8:12 a.m. | OK | GNU C++14 | TESTS | 124 | 1404 | 49664000 | 3000 | |
| 60717007 | Rubbish12345 | E | Sept. 17, 2019, 11:03 a.m. | OK | GNU C++17 | TESTS | 124 | 1590 | 44032000 | 3000 | |
| 59971341 | Dup4 | E | Sept. 4, 2019, 1:34 a.m. | OK | GNU C++17 | TESTS | 124 | 1684 | 34508800 | 3000 | |
| 47622826 | Zhang_RQ | E | Dec. 28, 2018, 1:37 p.m. | OK | GNU C++17 | TESTS | 124 | 1731 | 239308800 | 3000 | |
| 60589306 | vjudge2 | E | Sept. 15, 2019, 12:32 a.m. | OK | GNU C++17 | TESTS | 124 | 1918 | 39116800 | 3000 | |
| 61585015 | vjudge5 | E | Oct. 1, 2019, 4:27 a.m. | OK | GNU C++17 | TESTS | 124 | 1918 | 112742400 | 3000 | |
| 42551489 | 2014CAIS01 | E | Sept. 6, 2018, 12:17 p.m. | OK | GNU C++17 | TESTS | 124 | 1996 | 179302400 | 3000 | |
| 54553382 | vjudge4 | E | May 24, 2019, 10:23 a.m. | OK | GNU C++17 | TESTS | 124 | 2012 | 45158400 | 3000 | |
| 47505849 | Joky_02 | E | Dec. 25, 2018, 11:25 p.m. | OK | GNU C++17 | TESTS | 124 | 2012 | 120320000 | 3000 | |
| 52489142 | Isonan | E | April 8, 2019, 10:48 a.m. | OK | GNU C++17 | TESTS | 124 | 2183 | 48128000 | 3000 | |
| 60390654 | Nakagawa.Kanon | E | Sept. 11, 2019, 1:11 p.m. | OK | GNU C++17 | TESTS | 124 | 2230 | 96563200 | 3000 | |
| 43021209 | fwat | E | Sept. 18, 2018, 5:07 a.m. | OK | MS C++ | TESTS | 124 | 1980 | 28364800 | 3000 | |
| 35584336 | Los_Angelos_Laycurse | E | Feb. 22, 2018, 9:55 p.m. | OK | MS C++ | TESTS | 124 | 7705 | 40345600 | 3000 |
Back to search problems