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"To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way: Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working. William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10 ). Description of the test cases follows. The only line for each test case contains two integers n and k ( 2 <= k <= n <= 10^5 ), which are the total number of lights and the length of subsegment of lights that are being checked, respectively. For each test case print the answer, 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} . Explanation of the first sample test case: Let's write out all possible sequences of light toggles, which will make the device complete its operation: Then the final expected value will be equal to frac{2}{6} + frac{3}{6} + frac{2}{6} + frac{2}{6} + frac{2}{6} + frac{3}{6} = frac{14}{6} = frac{7}{3} . Then the required output will be 333333338 , since 333333338 cdot 3 equiv 7 pmod{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 |
117939407 |
Suiseiseki |
E |
May 30, 2021, 11:13 p.m. |
OK |
GNU C++11 |
TESTS |
57 |
31 |
1024000 |
|
2600 |
117946869 |
Aestas16 |
E |
May 31, 2021, 3:35 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117945769 |
Little-aztl |
E |
May 31, 2021, 3:10 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117945172 |
Aestas26 |
E |
May 31, 2021, 2:54 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117944769 |
ThuylinhTran |
E |
May 31, 2021, 2:45 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117941654 |
DQ9911 |
E |
May 31, 2021, 1:02 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
46 |
819200 |
|
2600 |
117945364 |
Robert_JYH |
E |
May 31, 2021, 2:59 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
46 |
1638400 |
|
2600 |
117913060 |
xh092113 |
E |
May 30, 2021, 4:28 p.m. |
OK |
GNU C++11 |
TESTS |
57 |
46 |
2457600 |
|
2600 |
117953887 |
Huah |
E |
May 31, 2021, 5:27 a.m. |
OK |
GNU C++11 |
TESTS |
57 |
46 |
3174400 |
|
2600 |
117909900 |
AlmostComplete |
E |
May 30, 2021, 4:15 p.m. |
OK |
GNU C++11 |
TESTS |
57 |
46 |
3174400 |
|
2600 |
117936891 |
krijgertje |
E |
May 30, 2021, 9:19 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
31 |
1228800 |
|
2600 |
117939332 |
Potassium |
E |
May 30, 2021, 11:09 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
46 |
3174400 |
|
2600 |
117909290 |
Hollowed |
E |
May 30, 2021, 4:12 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
62 |
6451200 |
|
2600 |
117941958 |
shirakami_fbk |
E |
May 31, 2021, 1:15 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
109 |
3993600 |
|
2600 |
117949763 |
vjudge3 |
E |
May 31, 2021, 4:33 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
265 |
819200 |
|
2600 |
117941808 |
tzxydby |
E |
May 31, 2021, 1:10 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
280 |
819200 |
|
2600 |
117936581 |
ne_deyan |
E |
May 30, 2021, 9:10 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
374 |
1638400 |
|
2600 |
117918158 |
rng_59 |
E |
May 30, 2021, 4:48 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
499 |
1638400 |
|
2600 |
117953747 |
8e7 |
E |
May 31, 2021, 5:25 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
499 |
3174400 |
|
2600 |
117916144 |
Marckess |
E |
May 30, 2021, 4:40 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
514 |
3174400 |
|
2600 |
117938344 |
schiftyfive4 |
E |
May 30, 2021, 10:20 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
31 |
819200 |
|
2600 |
117912563 |
cxy004 |
E |
May 30, 2021, 4:26 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
31 |
1228800 |
|
2600 |
117954362 |
333lfy |
E |
May 31, 2021, 5:33 a.m. |
OK |
GNU C++17 |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117909615 |
wudi2016 |
E |
May 30, 2021, 4:14 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
31 |
6451200 |
|
2600 |
117947694 |
2919805063 |
E |
May 31, 2021, 3:52 a.m. |
OK |
GNU C++17 |
TESTS |
57 |
46 |
819200 |
|
2600 |
117917139 |
bogdan10bos |
E |
May 30, 2021, 4:44 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
46 |
1638400 |
|
2600 |
117943219 |
potato167 |
E |
May 31, 2021, 2:01 a.m. |
OK |
GNU C++17 |
TESTS |
57 |
46 |
2662400 |
|
2600 |
117911635 |
PrincessConsuela |
E |
May 30, 2021, 4:22 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
46 |
3174400 |
|
2600 |
117922494 |
viskonsin |
E |
May 30, 2021, 5:37 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
46 |
3993600 |
|
2600 |
117915727 |
MonkeyKing |
E |
May 30, 2021, 4:39 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
61 |
1638400 |
|
2600 |
117941749 |
Mivik |
E |
May 31, 2021, 1:07 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
819200 |
|
2600 |
117944923 |
clam |
E |
May 31, 2021, 2:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
1228800 |
|
2600 |
117920651 |
hzk_cpp |
E |
May 30, 2021, 5:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
1228800 |
|
2600 |
117920427 |
Akemi-Homura- |
E |
May 30, 2021, 5:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
1228800 |
|
2600 |
117938702 |
smax |
E |
May 30, 2021, 10:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
1638400 |
|
2600 |
117918897 |
HolyK |
E |
May 30, 2021, 4:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
3174400 |
|
2600 |
117910641 |
Um_nik |
E |
May 30, 2021, 4:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
3276800 |
|
2600 |
117909814 |
rniya |
E |
May 30, 2021, 4:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
3481600 |
|
2600 |
117949288 |
Sakuyalove |
E |
May 31, 2021, 4:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
4812800 |
|
2600 |
117917094 |
practice_go |
E |
May 30, 2021, 4:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
31 |
4812800 |
|
2600 |
117910461 |
uwi |
E |
May 30, 2021, 4:17 p.m. |
OK |
Java 11 |
TESTS |
57 |
280 |
0 |
|
2600 |
117913811 |
dalt |
E |
May 30, 2021, 4:31 p.m. |
OK |
Java 8 |
TESTS |
57 |
202 |
9113600 |
|
2600 |
117921350 |
Tlatoani |
E |
May 30, 2021, 5:30 p.m. |
OK |
Kotlin |
TESTS |
57 |
326 |
0 |
|
2600 |
117944519 |
PinkPanicKing |
E |
May 31, 2021, 2:38 a.m. |
OK |
PyPy 2 |
TESTS |
57 |
826 |
89292800 |
|
2600 |
117928626 |
codicon |
E |
May 30, 2021, 6:46 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
560 |
36659200 |
|
2600 |
117941163 |
tkacper |
E |
May 31, 2021, 12:37 a.m. |
OK |
PyPy 3 |
TESTS |
57 |
561 |
17510400 |
|
2600 |
117938708 |
silvertint |
E |
May 30, 2021, 10:36 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
717 |
14745600 |
|
2600 |
117929901 |
sh1194 |
E |
May 30, 2021, 7:04 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
1294 |
25702400 |
|
2600 |
117921769 |
complexroots |
E |
May 30, 2021, 5:33 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
1294 |
25702400 |
|
2600 |
117929823 |
sh1194 |
E |
May 30, 2021, 7:03 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
1309 |
25702400 |
|
2600 |
117929759 |
sh1194 |
E |
May 30, 2021, 7:02 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
1325 |
25702400 |
|
2600 |
117921094 |
complexroots |
E |
May 30, 2021, 5:29 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
2183 |
26624000 |
|
2600 |
117940669 |
tkacper |
E |
May 31, 2021, 12:14 a.m. |
OK |
Python 3 |
TESTS |
57 |
2682 |
5734400 |
|
2600 |
117938023 |
nikgaevoy |
E |
May 30, 2021, 10:04 p.m. |
OK |
Rust |
TESTS |
57 |
1248 |
2457600 |
|
2600 |
remove filters
Back to search problems