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'Mr. Chanek opened a letter from his fellow, who is currently studying at Singanesia. Here is what it says. Define an array b ( 0 <= q b_i < k ) with n integers. While there exists a pair (i, j) such that b_i ne b_j , do the following operation: Denote f(b) as the expected number of operations done to b until all elements of b are equal. You are given two integers n and k , and an array a ( -1 <= q a_i < k ) of n integers. For every index i with a_i = -1 , replace a_i with a random number j satisfying 0 <= q j < k . Let c be the number of occurrences of -1 in a . There are k^c possibilites of a after the replacement, each with equal probability of being the final array. Find the expected value of f(a) modulo 10^9 + 7 . Formally, let M = 10^9 + 7 . It can be shown that the answer can be expressed as an irreducible fraction frac{p}{q} , where p and q are integers and q not equiv 0 pmod{M} . Output the integer equal to p cdot q^{-1} bmod M . In other words, output such an integer x that 0 <= x < M and x cdot q equiv p pmod{M} . After reading the letter, Mr. Chanek gave the task to you. Solve it for the sake of their friendship! The first line contains two integers n and k ( 2 <= q n <= q 10^5 , 2 <= q k <= q 10^9 ). The second line contains n integers a_1, a_2, ldots, a_n ( -1 <= q a_i < k ). Output an integer denoting the expected value of f(a) modulo 10^9 + 7 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
130587755 |
aarr afterall Amoo_Safar |
F |
Oct. 2, 2021, 5:34 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
326 |
11980800 |
|
|
130584385 |
gisp_zjz |
F |
Oct. 2, 2021, 4:49 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
514 |
9728000 |
|
|
130594445 |
chemthan |
F |
Oct. 2, 2021, 7:14 p.m. |
OK |
GNU C++17 |
TESTS |
105 |
686 |
152780800 |
|
|
130590578 |
Heltion |
F |
Oct. 2, 2021, 6:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
105 |
78 |
12185600 |
|
|
130601555 |
hos.lyric |
F |
Oct. 2, 2021, 9:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
105 |
93 |
13107200 |
|
|
130573936 |
Retired_MiFaFaOvO TLE Miracle03 |
F |
Oct. 2, 2021, 2:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
105 |
187 |
30310400 |
|
|
130579143 |
triple__a kimoyami Roundgod |
F |
Oct. 2, 2021, 3:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
105 |
311 |
26316800 |
|
|
130601261 |
errorgorn |
F |
Oct. 2, 2021, 9:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
105 |
2074 |
25804800 |
|
|
130584389 |
insert_cool_handle |
F |
Oct. 2, 2021, 4:49 p.m. |
OK |
Java 11 |
TESTS |
105 |
655 |
24268800 |
|
|
remove filters
Back to search problems