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'A positive number x of length n in base p ( 2 <= p <= 10^9 ) is written on the blackboard. The number x is given as a sequence a_1, a_2, ... , a_n ( 0 <= a_i < p ) -- the digits of x in order from left to right (most significant to least significant). Dmitry is very fond of all the digits of this number system, so he wants to see each of them at least once. In one operation, he can: For example, p=5 and x=234_5 . Your task is to determine the minimum number of operations required to make all the digits from 0 to p-1 appear on the board at least once. The first line of the input contains a single integer t ( 1 <= t <= 2 cdot 10^3 ) -- the number of test cases. The descriptions of the input test cases follow. The first line of description of each test case contains two integers n ( 1 <= n <= 100 ) and p ( 2 <= p <= 10^9 ) -- the length of the number and the base of the number system. The second line of the description of each test case contains n integers a_1, a_2, ... , a_n ( 0 <= a_i < p ) -- digits of x in number system with base p It is guaranteed that the number x does not contain leading zeros (that is, a_1>0 ). For each test case print a single integer -- the minimum number of operations required for Dmitry to get all the digits on the board from 0 to p-1 . It can be shown that this always requires a finite number of operations. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
181537247 |
Moka50 |
F |
Nov. 18, 2022, 8:09 p.m. |
OK |
GNU C11 |
TESTS |
29 |
93 |
0 |
|
|
181510856 |
The_Greatest_Code |
F |
Nov. 18, 2022, 4:43 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
62 |
0 |
|
|
181515041 |
yinhee |
F |
Nov. 18, 2022, 4:52 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
62 |
2150400 |
|
|
181550613 |
prairie2022 |
F |
Nov. 19, 2022, 1:58 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
77 |
0 |
|
|
181512677 |
Tahsin13 |
F |
Nov. 18, 2022, 4:47 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
77 |
204800 |
|
|
181519950 |
sourav_suku |
F |
Nov. 18, 2022, 5:17 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
77 |
204800 |
|
|
181527706 |
Invisible_Shadow |
F |
Nov. 18, 2022, 6:21 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
77 |
204800 |
|
|
181523560 |
SkyWalkerPS |
F |
Nov. 18, 2022, 5:42 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
78 |
204800 |
|
|
181527424 |
Pushkar27 |
F |
Nov. 18, 2022, 6:19 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
78 |
204800 |
|
|
181563754 |
heitailang |
F |
Nov. 19, 2022, 5:41 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
78 |
204800 |
|
|
181527076 |
Gabriel98 |
F |
Nov. 18, 2022, 6:15 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
78 |
204800 |
|
|
181510930 |
liar_frisky |
F |
Nov. 18, 2022, 4:43 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
0 |
|
|
181516492 |
hexatriene |
F |
Nov. 18, 2022, 4:58 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
102400 |
|
|
181560251 |
striver_07 |
F |
Nov. 19, 2022, 4:55 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
204800 |
|
|
181515468 |
willwin4sure |
F |
Nov. 18, 2022, 4:54 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
204800 |
|
|
181516163 |
regian0001 |
F |
Nov. 18, 2022, 4:57 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
6553600 |
|
|
181511702 |
huang_cc |
F |
Nov. 18, 2022, 4:45 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
77 |
0 |
|
|
181512733 |
hazzzu |
F |
Nov. 18, 2022, 4:47 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
77 |
102400 |
|
|
181561370 |
rifatrraazz |
F |
Nov. 19, 2022, 5:11 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
77 |
102400 |
|
|
181561294 |
Sara.S. |
F |
Nov. 19, 2022, 5:10 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
77 |
102400 |
|
|
181521833 |
Stimsly |
F |
Nov. 18, 2022, 5:29 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
77 |
102400 |
|
|
181513552 |
one_day |
F |
Nov. 18, 2022, 4:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
102400 |
|
|
181542115 |
enslaved |
F |
Nov. 18, 2022, 9:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
61 |
204800 |
|
|
181557618 |
ingingin |
F |
Nov. 19, 2022, 4:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181555348 |
Aoisrot |
F |
Nov. 19, 2022, 3:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181551505 |
prashar32 |
F |
Nov. 19, 2022, 2:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181515179 |
Edu175 |
F |
Nov. 18, 2022, 4:53 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181550551 |
CurryWOE |
F |
Nov. 19, 2022, 1:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181562536 |
harshaa05 |
F |
Nov. 19, 2022, 5:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
0 |
|
|
181556378 |
kittarshire |
F |
Nov. 19, 2022, 3:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
62 |
102400 |
|
|
181555251 |
Kellyz |
F |
Nov. 19, 2022, 3:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
77 |
0 |
|
|
181518274 |
Artur_Gaspar |
F |
Nov. 18, 2022, 5:08 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181563529 |
bhavyrajdev0 |
F |
Nov. 19, 2022, 5:39 a.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181542944 |
ShashankZobb |
F |
Nov. 18, 2022, 9:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181523996 |
Ankit_132 |
F |
Nov. 18, 2022, 5:47 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181523530 |
abotaha23 |
F |
Nov. 18, 2022, 5:42 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181517422 |
ak_shrana |
F |
Nov. 18, 2022, 5:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181511925 |
blueblueb1lue |
F |
Nov. 18, 2022, 4:45 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
0 |
|
|
181534963 |
Satinii |
F |
Nov. 18, 2022, 7:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
102400 |
|
|
181529505 |
hafiz_sakib |
F |
Nov. 18, 2022, 6:40 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
102400 |
|
|
181536636 |
ishwarendra |
F |
Nov. 18, 2022, 8:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
46 |
102400 |
|
|
181510993 |
dzhi |
F |
Nov. 18, 2022, 4:43 p.m. |
OK |
Java 11 |
TESTS |
29 |
374 |
0 |
|
|
181525899 |
HeXecutor |
F |
Nov. 18, 2022, 6:03 p.m. |
OK |
Java 11 |
TESTS |
29 |
467 |
0 |
|
|
181516934 |
Mamimi |
F |
Nov. 18, 2022, 5:01 p.m. |
OK |
Java 17 |
TESTS |
29 |
296 |
819200 |
|
|
181515539 |
merlin_ |
F |
Nov. 18, 2022, 4:54 p.m. |
OK |
Java 17 |
TESTS |
29 |
950 |
409600 |
|
|
181535549 |
Mohamed_A7med |
F |
Nov. 18, 2022, 7:48 p.m. |
OK |
Java 8 |
TESTS |
29 |
171 |
0 |
|
|
181513938 |
invincible777 |
F |
Nov. 18, 2022, 4:49 p.m. |
OK |
Java 8 |
TESTS |
29 |
217 |
0 |
|
|
181516338 |
mumuxinfei |
F |
Nov. 18, 2022, 4:58 p.m. |
OK |
Java 8 |
TESTS |
29 |
436 |
0 |
|
|
181547075 |
hotkey |
F |
Nov. 19, 2022, 12:10 a.m. |
OK |
Kotlin 1.6 |
TESTS |
29 |
405 |
1740800 |
|
|
181510855 |
gelbelachente |
F |
Nov. 18, 2022, 4:43 p.m. |
OK |
Kotlin 1.7 |
TESTS |
29 |
748 |
62464000 |
|
|
181510946 |
fireSlayer57 |
F |
Nov. 18, 2022, 4:43 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
451 |
9728000 |
|
|
181544815 |
Lammert0907 |
F |
Nov. 18, 2022, 10:45 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
576 |
9830400 |
|
|
181556872 |
bokunopicolo |
F |
Nov. 19, 2022, 4 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
140 |
9420800 |
|
|
181537601 |
hkwu6013 |
F |
Nov. 18, 2022, 8:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
155 |
9216000 |
|
|
181517739 |
blue_ice_yj |
F |
Nov. 18, 2022, 5:05 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
171 |
9728000 |
|
|
181547782 |
BeBeBe66666 |
F |
Nov. 19, 2022, 12:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
186 |
9932800 |
|
|
181549391 |
Little_Sheep_Yawn |
F |
Nov. 19, 2022, 1:28 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
234 |
14745600 |
|
|
181532353 |
Slamur |
F |
Nov. 18, 2022, 7:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
249 |
10137600 |
|
|
181519306 |
grandb369 |
F |
Nov. 18, 2022, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
249 |
10342400 |
|
|
181514145 |
crap_the_coder |
F |
Nov. 18, 2022, 4:49 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
264 |
10035200 |
|
|
181541147 |
biglunchdude |
F |
Nov. 18, 2022, 9:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
311 |
9932800 |
|
|
181561747 |
fathorse |
F |
Nov. 19, 2022, 5:16 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
420 |
9932800 |
|
|
181537178 |
a2bailey |
F |
Nov. 18, 2022, 8:08 p.m. |
OK |
Python 3 |
TESTS |
29 |
124 |
512000 |
|
|
181515458 |
debashishmahanta1 |
F |
Nov. 18, 2022, 4:54 p.m. |
OK |
Python 3 |
TESTS |
29 |
140 |
307200 |
|
|
181512632 |
lrjr24 |
F |
Nov. 18, 2022, 4:47 p.m. |
OK |
Python 3 |
TESTS |
29 |
1403 |
512000 |
|
|
181511873 |
carlfre |
F |
Nov. 18, 2022, 4:45 p.m. |
OK |
Python 3 |
TESTS |
29 |
2230 |
512000 |
|
|
181546887 |
liut |
F |
Nov. 19, 2022, 12:03 a.m. |
OK |
Rust 2021 |
TESTS |
29 |
46 |
102400 |
|
|
181555036 |
avnyu |
F |
Nov. 19, 2022, 3:28 a.m. |
OK |
Rust 2021 |
TESTS |
29 |
140 |
15667200 |
|
|
remove filters
Back to search problems