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'Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n . You will move the token up until it arrives at cell 1 . Let the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: Find the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m . Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding). The only line contains two integers n and m ( 2 <= n <= 4 cdot 10^6 ; 10^8 < m < 10^9 ; m is a prime number) -- the length of the strip and the modulo. Print the number of ways to move the token from cell n to cell 1 , modulo m . In the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2 , or using division by z = 2 or z = 3 . There are also two ways to move the token from cell 3 to cell 1 via cell 2 : first subtract y = 1 , and then either subtract y = 1 again or divide by z = 2 . Therefore, there are five ways in total. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
126941755 |
Leasier |
B |
Aug. 25, 2021, 6:45 a.m. |
OK |
GNU C11 |
TESTS |
25 |
842 |
67788800 |
|
1900 |
126941832 |
Leasier |
B |
Aug. 25, 2021, 6:46 a.m. |
OK |
GNU C11 |
TESTS |
25 |
857 |
67788800 |
|
1900 |
126942193 |
Leasier |
B |
Aug. 25, 2021, 6:50 a.m. |
OK |
GNU C11 |
TESTS |
25 |
904 |
67788800 |
|
1900 |
126902233 |
shirowa |
B |
Aug. 24, 2021, 4:56 p.m. |
OK |
GNU C11 |
TESTS |
24 |
1575 |
35737600 |
|
1900 |
126922727 |
Leasier |
B |
Aug. 25, 2021, 12:58 a.m. |
OK |
GNU C11 |
TESTS |
25 |
2370 |
67788800 |
|
1900 |
126940938 |
Shik2005 |
B |
Aug. 25, 2021, 6:34 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
529 |
35840000 |
|
1900 |
126884848 |
zqy1018 |
B |
Aug. 24, 2021, 4:02 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
608 |
35840000 |
|
1900 |
126898100 |
Sohsoh84 |
B |
Aug. 24, 2021, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
623 |
99942400 |
|
1900 |
126935085 |
S_test |
B |
Aug. 25, 2021, 5:14 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
639 |
35840000 |
|
1900 |
126976694 |
pufanyi |
B |
Aug. 25, 2021, 2:20 p.m. |
OK |
GNU C++14 |
TESTS |
33 |
655 |
19763200 |
|
1900 |
126854108 |
Isonan |
B |
Aug. 24, 2021, 2:51 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
655 |
19763200 |
|
1900 |
126873599 |
maojiayi |
B |
Aug. 24, 2021, 3:33 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
685 |
51814400 |
|
1900 |
126880124 |
nhho |
B |
Aug. 24, 2021, 3:49 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
686 |
19763200 |
|
1900 |
126921454 |
SrO |
B |
Aug. 25, 2021, 12:10 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
686 |
35840000 |
|
1900 |
126879934 |
KurisuMakise |
B |
Aug. 24, 2021, 3:49 p.m. |
OK |
GNU C++14 |
TESTS |
24 |
686 |
67891200 |
|
1900 |
126879942 |
Pigbrain |
B |
Aug. 24, 2021, 3:49 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
499 |
19763200 |
|
1900 |
126857072 |
couplefire |
B |
Aug. 24, 2021, 2:57 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
545 |
35840000 |
|
1900 |
126865821 |
T404 |
B |
Aug. 24, 2021, 3:15 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
561 |
19763200 |
|
1900 |
126868321 |
PurpleWonder |
B |
Aug. 24, 2021, 3:21 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
577 |
19763200 |
|
1900 |
126915175 |
fxhd |
B |
Aug. 24, 2021, 8:02 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
608 |
35840000 |
|
1900 |
126854336 |
BigBag |
B |
Aug. 24, 2021, 2:51 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
623 |
35840000 |
|
1900 |
126857862 |
BuShangGMBuGaiMing |
B |
Aug. 24, 2021, 2:59 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
623 |
35840000 |
|
1900 |
126924812 |
bkifhr7 |
B |
Aug. 25, 2021, 1:59 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
623 |
35840000 |
|
1900 |
126911157 |
abeker |
B |
Aug. 24, 2021, 6:44 p.m. |
OK |
GNU C++17 |
TESTS |
24 |
624 |
19763200 |
|
1900 |
126969368 |
ynycoding |
B |
Aug. 25, 2021, 12:48 p.m. |
OK |
GNU C++17 |
TESTS |
33 |
624 |
35737600 |
|
1900 |
126914192 |
Leeisateam |
B |
Aug. 24, 2021, 7:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
451 |
36352000 |
|
1900 |
126914201 |
Leeisateam |
B |
Aug. 24, 2021, 7:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
452 |
36352000 |
|
1900 |
126914199 |
Leeisateam |
B |
Aug. 24, 2021, 7:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
483 |
36352000 |
|
1900 |
126914193 |
Leeisateam |
B |
Aug. 24, 2021, 7:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
499 |
36352000 |
|
1900 |
126914140 |
Leeisateam |
B |
Aug. 24, 2021, 7:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
499 |
36352000 |
|
1900 |
126883855 |
jerry3128 |
B |
Aug. 24, 2021, 3:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
499 |
54784000 |
|
1900 |
126935151 |
rgnerdplayer |
B |
Aug. 25, 2021, 5:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
514 |
20377600 |
|
1900 |
126855538 |
QAQAutoMaton |
B |
Aug. 24, 2021, 2:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
514 |
40550400 |
|
1900 |
126861406 |
jiangIy |
B |
Aug. 24, 2021, 3:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
514 |
52428800 |
|
1900 |
126872690 |
777 |
B |
Aug. 24, 2021, 3:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
24 |
530 |
20377600 |
|
1900 |
126911176 |
clyring |
B |
Aug. 24, 2021, 6:45 p.m. |
OK |
Haskell |
TESTS |
24 |
904 |
45260800 |
|
1900 |
126902621 |
pulkit1411 |
B |
Aug. 24, 2021, 4:57 p.m. |
OK |
Java 11 |
TESTS |
24 |
1481 |
65331200 |
|
1900 |
126871504 |
Sohomot_Vai |
B |
Aug. 24, 2021, 3:28 p.m. |
OK |
Java 11 |
TESTS |
24 |
1497 |
65024000 |
|
1900 |
126867328 |
insert_cool_handle |
B |
Aug. 24, 2021, 3:19 p.m. |
OK |
Java 11 |
TESTS |
24 |
1512 |
64921600 |
|
1900 |
126856143 |
dalt |
B |
Aug. 24, 2021, 2:55 p.m. |
OK |
Java 11 |
TESTS |
24 |
1560 |
114790400 |
|
1900 |
126918975 |
mphillotry |
B |
Aug. 24, 2021, 10:01 p.m. |
OK |
Java 11 |
TESTS |
24 |
1591 |
39628800 |
|
1900 |
126868714 |
SecondThread |
B |
Aug. 24, 2021, 3:22 p.m. |
OK |
Java 8 |
TESTS |
24 |
1528 |
66764800 |
|
1900 |
126863344 |
YahiaSherif |
B |
Aug. 24, 2021, 3:10 p.m. |
OK |
Java 8 |
TESTS |
24 |
1653 |
42291200 |
|
1900 |
127008281 |
mshereef |
B |
Aug. 26, 2021, 1:22 a.m. |
OK |
Java 8 |
TESTS |
33 |
1700 |
42393600 |
|
1900 |
127002592 |
smahajan54842 |
B |
Aug. 25, 2021, 8:58 p.m. |
OK |
Java 8 |
TESTS |
33 |
2683 |
114995200 |
|
1900 |
126859233 |
fetetriste |
B |
Aug. 24, 2021, 3:03 p.m. |
OK |
Java 8 |
TESTS |
24 |
2838 |
70041600 |
|
1900 |
126895503 |
Hakiobo |
B |
Aug. 24, 2021, 4:33 p.m. |
OK |
Kotlin |
TESTS |
24 |
1653 |
58572800 |
|
1900 |
126883390 |
arvindf232 |
B |
Aug. 24, 2021, 3:58 p.m. |
OK |
Kotlin |
TESTS |
24 |
2496 |
86323200 |
|
1900 |
126894676 |
Gmacem |
B |
Aug. 24, 2021, 4:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
24 |
2823 |
99942400 |
|
1900 |
126868790 |
azukun |
B |
Aug. 24, 2021, 3:22 p.m. |
OK |
.NET Core C# |
TESTS |
24 |
3057 |
79052800 |
|
1900 |
126912064 |
titia |
B |
Aug. 24, 2021, 6:59 p.m. |
OK |
PyPy 3 |
TESTS |
24 |
1419 |
54067200 |
|
1900 |
126999048 |
RANK1ZEN |
B |
Aug. 25, 2021, 7:32 p.m. |
OK |
PyPy 3 |
TESTS |
33 |
1653 |
54272000 |
|
1900 |
126897219 |
misorin |
B |
Aug. 24, 2021, 4:39 p.m. |
OK |
PyPy 3 |
TESTS |
24 |
1746 |
54169600 |
|
1900 |
126966150 |
eepsilon |
B |
Aug. 25, 2021, 12:01 p.m. |
OK |
PyPy 3 |
TESTS |
33 |
1996 |
37785600 |
|
1900 |
126867931 |
chinerist |
B |
Aug. 24, 2021, 3:20 p.m. |
OK |
PyPy 3 |
TESTS |
24 |
2183 |
96768000 |
|
1900 |
127006265 |
lebron87 |
B |
Aug. 25, 2021, 11:46 p.m. |
OK |
PyPy 3 |
TESTS |
33 |
2199 |
86630400 |
|
1900 |
127006027 |
lebron87 |
B |
Aug. 25, 2021, 11:30 p.m. |
OK |
PyPy 3 |
TESTS |
33 |
2542 |
86732800 |
|
1900 |
126910355 |
sansen |
B |
Aug. 24, 2021, 6:32 p.m. |
OK |
Rust |
TESTS |
24 |
576 |
19865600 |
|
1900 |
126911615 |
sansen |
B |
Aug. 24, 2021, 6:51 p.m. |
OK |
Rust |
TESTS |
24 |
607 |
35840000 |
|
1900 |
126898676 |
sansen |
B |
Aug. 24, 2021, 4:44 p.m. |
OK |
Rust |
TESTS |
24 |
624 |
35840000 |
|
1900 |
126907960 |
sansen |
B |
Aug. 24, 2021, 6:04 p.m. |
OK |
Rust |
TESTS |
24 |
779 |
35840000 |
|
1900 |
126955552 |
cottoncotton |
B |
Aug. 25, 2021, 9:30 a.m. |
OK |
Rust |
TESTS |
31 |
1559 |
35942400 |
|
1900 |
126881925 |
apilat |
B |
Aug. 24, 2021, 3:54 p.m. |
OK |
Rust |
TESTS |
24 |
2449 |
35840000 |
|
1900 |
remove filters
Back to search problems