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"Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number ai is written on the i-th card in the deck. After receiving the deck and the magic number, Vova removes x (possibly x xe2 x80 x89= xe2 x80 x890) cards from the top of the deck, y (possibly y xe2 x80 x89= xe2 x80 x890) cards from the bottom of the deck, and the rest of the deck is his new deck (Vova has to leave at least one card in the deck after removing cards). So Vova's new deck actually contains cards x xe2 x80 x89+ xe2 x80 x891, x xe2 x80 x89+ xe2 x80 x892, ... n xe2 x80 x89- xe2 x80 x89y xe2 x80 x89- xe2 x80 x891, n xe2 x80 x89- xe2 x80 x89y from the original deck. Vova's new deck is considered valid iff the product of all numbers written on the cards in his new deck is divisible by k. So Vova received a deck (possibly not a valid one) and a number k, and now he wonders, how many ways are there to choose x and y so the deck he will get after removing x cards from the top and y cards from the bottom is valid? The first line contains two integers n and k (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89100 xe2 x80 x89000, 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89k xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109). The second line contains n integers a1, a2, ..., an (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) -- the numbers written on the cards. Print the number of ways to choose x and y so the resulting deck is valid. In the first example the possible values of x and y are: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
28157964 |
nanae1914 |
E |
June 29, 2017, 8:32 p.m. |
OK |
D |
TESTS |
135 |
62 |
14745600 |
|
2000 |
28167588 |
fluffyowl |
E |
June 30, 2017, 8:32 a.m. |
OK |
D |
TESTS |
135 |
265 |
14745600 |
|
2000 |
28156879 |
ruban |
E |
June 29, 2017, 7:13 p.m. |
OK |
Delphi |
TESTS |
135 |
62 |
214937600 |
|
2000 |
28156883 |
ruban |
E |
June 29, 2017, 7:13 p.m. |
OK |
FPC |
TESTS |
135 |
46 |
214016000 |
|
2000 |
28260564 |
Minh_love_Hong_Phuc |
E |
July 3, 2017, 4:24 p.m. |
OK |
FPC |
TESTS |
135 |
592 |
9625600 |
|
2000 |
29527898 |
slavik228 |
E |
Aug. 17, 2017, 2:07 p.m. |
OK |
FPC |
TESTS |
135 |
936 |
2048000 |
|
2000 |
28156182 |
rainboy |
E |
June 29, 2017, 6:29 p.m. |
OK |
GNU C |
TESTS |
135 |
31 |
8294400 |
|
2000 |
28325740 |
AltF4 |
E |
July 6, 2017, 11:49 a.m. |
OK |
GNU C |
TESTS |
135 |
46 |
8294400 |
|
2000 |
28147461 |
sgtlaugh |
E |
June 29, 2017, 3:55 p.m. |
OK |
GNU C |
TESTS |
135 |
234 |
9523200 |
|
2000 |
28350529 |
131441373 |
E |
July 7, 2017, 1:43 p.m. |
OK |
GNU C++ |
TESTS |
135 |
30 |
16691200 |
|
2000 |
28297935 |
evpipis |
E |
July 5, 2017, 7:46 a.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
2457600 |
|
2000 |
28184198 |
sam721 |
E |
July 1, 2017, 5:04 a.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
3174400 |
|
2000 |
28636614 |
tapopadma |
E |
July 17, 2017, 10:36 a.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
4096000 |
|
2000 |
28149268 |
cyand1317 |
E |
June 29, 2017, 4:13 p.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
5939200 |
|
2000 |
28193875 |
SayedEl-Abady |
E |
July 1, 2017, 3:04 p.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
6144000 |
|
2000 |
29544880 |
bojverdict1 |
E |
Aug. 18, 2017, 6:47 a.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
14028800 |
|
2000 |
33045025 |
Scut82 |
E |
Dec. 9, 2017, 9:50 a.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
22118400 |
|
2000 |
28154305 |
dxm439 |
E |
June 29, 2017, 5:17 p.m. |
OK |
GNU C++ |
TESTS |
135 |
31 |
44544000 |
|
2000 |
29784562 |
vjudge1 |
E |
Aug. 25, 2017, 3 p.m. |
OK |
GNU C++ |
TESTS |
135 |
46 |
409600 |
|
2000 |
28209275 |
fsociety00 |
E |
July 2, 2017, 11:33 a.m. |
OK |
GNU C11 |
TESTS |
135 |
46 |
19558400 |
|
2000 |
28203349 |
g1n0st |
E |
July 2, 2017, 4:55 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
30 |
10240000 |
|
2000 |
31948261 |
vjudge4 |
E |
Nov. 1, 2017, 11:46 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
409600 |
|
2000 |
28267829 |
AkaneSasu |
E |
July 4, 2017, 1:58 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2252800 |
|
2000 |
28155985 |
rashish2202 |
E |
June 29, 2017, 6:19 p.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2457600 |
|
2000 |
28262266 |
dredwerkz |
E |
July 3, 2017, 6:10 p.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2457600 |
|
2000 |
28186668 |
Ilya_ |
E |
July 1, 2017, 7:49 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2560000 |
|
2000 |
28186625 |
Ilya_ |
E |
July 1, 2017, 7:46 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2560000 |
|
2000 |
28186521 |
Ilya_ |
E |
July 1, 2017, 7:41 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2560000 |
|
2000 |
28186303 |
Ilya_ |
E |
July 1, 2017, 7:30 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2560000 |
|
2000 |
28319600 |
SiriusRen |
E |
July 6, 2017, 7:37 a.m. |
OK |
GNU C++11 |
TESTS |
135 |
31 |
2560000 |
|
2000 |
28147501 |
natsugiri |
E |
June 29, 2017, 3:55 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
31 |
2355200 |
|
2000 |
28176449 |
zoomswk |
E |
June 30, 2017, 3:59 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
31 |
8294400 |
|
2000 |
29592541 |
LEOLEI |
E |
Aug. 19, 2017, 8:11 a.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
409600 |
|
2000 |
48857609 |
ritik3000 |
E |
Jan. 23, 2019, 7:39 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
409600 |
|
2000 |
31948269 |
simulator |
E |
Nov. 1, 2017, 11:46 a.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
409600 |
|
2000 |
63370651 |
JVJplus |
E |
Oct. 25, 2019, 9:14 a.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
614400 |
|
2000 |
69004881 |
Gazra |
E |
Jan. 17, 2020, 10:10 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
819200 |
|
2000 |
32290500 |
21August |
E |
Nov. 13, 2017, 5:16 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
819200 |
|
2000 |
29957885 |
Fortin |
E |
Aug. 31, 2017, 7:35 p.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
819200 |
|
2000 |
30194009 |
Yasola |
E |
Sept. 8, 2017, 3:08 a.m. |
OK |
GNU C++14 |
TESTS |
135 |
46 |
1843200 |
|
2000 |
54717296 |
ZhihuiLiu |
E |
May 27, 2019, 2:07 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
46 |
409600 |
|
2000 |
35901829 |
AsahiKasugano |
E |
March 3, 2018, 8:53 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
46 |
5939200 |
|
2000 |
62428866 |
codekode |
E |
Oct. 12, 2019, 3:09 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
61 |
1638400 |
|
2000 |
60955666 |
qinding |
E |
Sept. 21, 2019, 2:25 a.m. |
OK |
GNU C++17 |
TESTS |
135 |
61 |
4403200 |
|
2000 |
51473816 |
amnesiac_dusk |
E |
March 19, 2019, 8:14 a.m. |
OK |
GNU C++17 |
TESTS |
135 |
61 |
7270400 |
|
2000 |
65297754 |
yizhibaiwuya |
E |
Nov. 18, 2019, 12:09 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
61 |
7987200 |
|
2000 |
69707322 |
hopeandlearn |
E |
Jan. 29, 2020, 5:22 a.m. |
OK |
GNU C++17 |
TESTS |
135 |
62 |
409600 |
|
2000 |
50614137 |
ShJ |
E |
Feb. 28, 2019, 6:30 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
62 |
409600 |
|
2000 |
69206098 |
xyz. |
E |
Jan. 20, 2020, 6:03 p.m. |
OK |
GNU C++17 |
TESTS |
135 |
62 |
819200 |
|
2000 |
59563793 |
Juve45 |
E |
Aug. 27, 2019, 9:48 a.m. |
OK |
GNU C++17 |
TESTS |
135 |
62 |
819200 |
|
2000 |
29339980 |
codeonwort |
E |
Aug. 10, 2017, 11:51 p.m. |
OK |
Haskell |
TESTS |
135 |
139 |
65024000 |
|
2000 |
68369033 |
its_aks_ulure |
E |
Jan. 7, 2020, 5:02 p.m. |
OK |
Java 11 |
TESTS |
135 |
655 |
36556800 |
|
2000 |
28255693 |
hitesh.bothra |
E |
July 3, 2017, 12:46 p.m. |
OK |
Java 8 |
TESTS |
135 |
124 |
20582400 |
|
2000 |
28155093 |
uwi |
E |
June 29, 2017, 5:38 p.m. |
OK |
Java 8 |
TESTS |
135 |
140 |
20582400 |
|
2000 |
28179784 |
Musin |
E |
June 30, 2017, 8:05 p.m. |
OK |
Java 8 |
TESTS |
135 |
140 |
20684800 |
|
2000 |
28179473 |
Musin |
E |
June 30, 2017, 7:40 p.m. |
OK |
Java 8 |
TESTS |
135 |
140 |
20684800 |
|
2000 |
66743712 |
unicorn20141 |
E |
Dec. 12, 2019, 11:26 p.m. |
OK |
Java 8 |
TESTS |
135 |
155 |
0 |
|
2000 |
28164564 |
p1p13 |
E |
June 30, 2017, 5:44 a.m. |
OK |
Java 8 |
TESTS |
135 |
155 |
20684800 |
|
2000 |
28351033 |
Kammola |
E |
July 7, 2017, 2:13 p.m. |
OK |
Java 8 |
TESTS |
135 |
155 |
20992000 |
|
2000 |
28155796 |
Dukkha |
E |
June 29, 2017, 6:09 p.m. |
OK |
Java 8 |
TESTS |
135 |
155 |
21401600 |
|
2000 |
28164486 |
p1p13 |
E |
June 30, 2017, 5:39 a.m. |
OK |
Java 8 |
TESTS |
135 |
170 |
20684800 |
|
2000 |
28180910 |
Musin |
E |
June 30, 2017, 10:29 p.m. |
OK |
Java 8 |
TESTS |
135 |
171 |
20582400 |
|
2000 |
28153831 |
leign |
E |
June 29, 2017, 5:11 p.m. |
OK |
Mono C# |
TESTS |
135 |
93 |
20480000 |
|
2000 |
28395959 |
ME_AJUUUUUDAAA |
E |
July 10, 2017, 1:17 a.m. |
OK |
Mono C# |
TESTS |
135 |
170 |
23449600 |
|
2000 |
28151429 |
AnatolyTolstobrov |
E |
June 29, 2017, 4:39 p.m. |
OK |
MS C# |
TESTS |
135 |
62 |
15257600 |
|
2000 |
28312367 |
IleksaNott |
E |
July 5, 2017, 9:26 p.m. |
OK |
MS C# |
TESTS |
135 |
108 |
23859200 |
|
2000 |
28150088 |
og.kostya |
E |
June 29, 2017, 4:22 p.m. |
OK |
MS C# |
TESTS |
135 |
483 |
11264000 |
|
2000 |
29620066 |
Friska |
E |
Aug. 20, 2017, 11:53 a.m. |
OK |
MS C++ |
TESTS |
135 |
46 |
3788800 |
|
2000 |
28167437 |
GabiTulba |
E |
June 30, 2017, 8:23 a.m. |
OK |
MS C++ |
TESTS |
135 |
108 |
4300800 |
|
2000 |
29644281 |
bojverdict1 |
E |
Aug. 21, 2017, 1:10 p.m. |
OK |
MS C++ |
TESTS |
135 |
109 |
8601600 |
|
2000 |
37747152 |
Maffka |
E |
April 30, 2018, 11:48 a.m. |
OK |
MS C++ |
TESTS |
135 |
124 |
10342400 |
|
2000 |
28185335 |
miha715lev |
E |
July 1, 2017, 6:34 a.m. |
OK |
MS C++ |
TESTS |
135 |
124 |
27750400 |
|
2000 |
28194710 |
Euler2718 |
E |
July 1, 2017, 4:01 p.m. |
OK |
MS C++ |
TESTS |
135 |
405 |
2867200 |
|
2000 |
28149401 |
Cypi |
E |
June 29, 2017, 4:14 p.m. |
OK |
PyPy 2 |
TESTS |
135 |
140 |
33177600 |
|
2000 |
66639816 |
shiv1470 |
E |
Dec. 11, 2019, 2:18 p.m. |
OK |
PyPy 3 |
TESTS |
135 |
311 |
13107200 |
|
2000 |
28333735 |
your_conscience |
E |
July 6, 2017, 5:53 p.m. |
OK |
Python 2 |
TESTS |
135 |
904 |
19865600 |
|
2000 |
31156677 |
WNG |
E |
Oct. 8, 2017, 11:39 p.m. |
OK |
Python 2 |
TESTS |
135 |
1325 |
27955200 |
|
2000 |
remove filters
Back to search problems