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"William has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer k is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer k ) Note that after performing operations, numbers a and b may become negative as well. William wants to find out the minimal number of operations he would have to perform to make a equal to his favorite number c and b equal to his second favorite number d . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). Description of the test cases follows. The only line of each test case contains two integers c and d (0 <= c, d <= 10^9) , which are William's favorite numbers and which he wants a and b to be transformed into. For each test case output a single number, which is the minimal number of operations which William would have to perform to make a equal to c and b equal to d , or -1 if it is impossible to achieve this using the described operations. Let us demonstrate one of the suboptimal ways of getting a pair (3, 5) : "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
127387207 |
daniil_volkov |
A |
Aug. 29, 2021, 4:51 p.m. |
OK |
FPC |
TESTS |
9 |
62 |
3481600 |
|
800 |
127403113 |
SashaT9 |
A |
Aug. 29, 2021, 9:02 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127403230 |
SashaT9 |
A |
Aug. 29, 2021, 9:06 p.m. |
OK |
GNU C11 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127382192 |
Md.Asraful_Islam_Subbir |
A |
Aug. 29, 2021, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
9 |
61 |
3686400 |
|
800 |
127412988 |
milan_s1 |
A |
Aug. 30, 2021, 3:24 a.m. |
OK |
GNU C11 |
TESTS |
9 |
61 |
3686400 |
|
800 |
127416527 |
xuxubaobao |
A |
Aug. 30, 2021, 4:44 a.m. |
OK |
GNU C11 |
TESTS |
9 |
61 |
3686400 |
|
800 |
127385371 |
gowthamgopi444 |
A |
Aug. 29, 2021, 4:45 p.m. |
OK |
GNU C11 |
TESTS |
9 |
61 |
3788800 |
|
800 |
127404819 |
Kulido |
A |
Aug. 29, 2021, 10:03 p.m. |
OK |
GNU C11 |
TESTS |
9 |
62 |
3686400 |
|
800 |
127391111 |
Utkarsh99 |
A |
Aug. 29, 2021, 5:03 p.m. |
OK |
GNU C11 |
TESTS |
9 |
62 |
3686400 |
|
800 |
127397615 |
Nuku |
A |
Aug. 29, 2021, 6:46 p.m. |
OK |
GNU C11 |
TESTS |
9 |
62 |
3686400 |
|
800 |
127406105 |
dengziyue |
A |
Aug. 29, 2021, 11:07 p.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127408187 |
luogu_bot3 |
A |
Aug. 30, 2021, 12:57 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127412967 |
BILL666 |
A |
Aug. 30, 2021, 3:23 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127417977 |
p.ferrari |
A |
Aug. 30, 2021, 5:15 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127417527 |
hardy_9795 |
A |
Aug. 30, 2021, 5:05 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127416654 |
alexashu |
A |
Aug. 30, 2021, 4:47 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127416361 |
anoopraj46 |
A |
Aug. 30, 2021, 4:41 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127413626 |
freakdeep |
A |
Aug. 30, 2021, 3:39 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127412870 |
rushad_27 |
A |
Aug. 30, 2021, 3:20 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127412377 |
zhabuye |
A |
Aug. 30, 2021, 3:07 a.m. |
OK |
GNU C++14 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127394426 |
vaishg9876 |
A |
Aug. 29, 2021, 6:07 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127396431 |
myFightBack |
A |
Aug. 29, 2021, 6:28 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127401418 |
saish24 |
A |
Aug. 29, 2021, 8:10 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127402739 |
uyakO |
A |
Aug. 29, 2021, 8:50 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127403586 |
ali404 |
A |
Aug. 29, 2021, 9:18 p.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127409539 |
soham_roy8 |
A |
Aug. 30, 2021, 1:48 a.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127412423 |
Shejuti_Binte_Feroz |
A |
Aug. 30, 2021, 3:09 a.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127414911 |
px2020 |
A |
Aug. 30, 2021, 4:07 a.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3686400 |
|
800 |
127418400 |
cslgz09419122 |
A |
Aug. 30, 2021, 5:23 a.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127419817 |
XGodz_7 |
A |
Aug. 30, 2021, 5:50 a.m. |
OK |
GNU C++17 |
TESTS |
9 |
15 |
3788800 |
|
800 |
127404454 |
MazenBatrawi |
A |
Aug. 29, 2021, 9:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127404333 |
Geothermal |
A |
Aug. 29, 2021, 9:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127402424 |
Anish_aak |
A |
Aug. 29, 2021, 8:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127408339 |
hao_qing233 |
A |
Aug. 30, 2021, 1:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127405640 |
_Enigma__ |
A |
Aug. 29, 2021, 10:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127417746 |
CODERGARV |
A |
Aug. 30, 2021, 5:10 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127417131 |
mj_riffu |
A |
Aug. 30, 2021, 4:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127415882 |
Stream_jiojio |
A |
Aug. 30, 2021, 4:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127409067 |
nestling |
A |
Aug. 30, 2021, 1:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127408357 |
Krug129 |
A |
Aug. 30, 2021, 1:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
9 |
15 |
4300800 |
|
800 |
127403561 |
gourav02 |
A |
Aug. 29, 2021, 9:17 p.m. |
OK |
Java 11 |
TESTS |
9 |
171 |
24166400 |
|
800 |
127399077 |
solo07 |
A |
Aug. 29, 2021, 7:14 p.m. |
OK |
Java 11 |
TESTS |
9 |
186 |
23756800 |
|
800 |
127414033 |
dhruvil_8803 |
A |
Aug. 30, 2021, 3:48 a.m. |
OK |
Java 11 |
TESTS |
9 |
187 |
23756800 |
|
800 |
127402020 |
MishkaGrig |
A |
Aug. 29, 2021, 8:27 p.m. |
OK |
Java 11 |
TESTS |
9 |
202 |
23756800 |
|
800 |
127403966 |
adarsh_goku |
A |
Aug. 29, 2021, 9:32 p.m. |
OK |
Java 11 |
TESTS |
9 |
202 |
23859200 |
|
800 |
127395496 |
pratham_b |
A |
Aug. 29, 2021, 6:17 p.m. |
OK |
Java 11 |
TESTS |
9 |
249 |
23859200 |
|
800 |
127385657 |
T.S.F |
A |
Aug. 29, 2021, 4:46 p.m. |
OK |
Java 11 |
TESTS |
9 |
264 |
23756800 |
|
800 |
127398118 |
ilasiawo |
A |
Aug. 29, 2021, 6:55 p.m. |
OK |
Java 11 |
TESTS |
9 |
264 |
24473600 |
|
800 |
127397180 |
ak_ankit |
A |
Aug. 29, 2021, 6:39 p.m. |
OK |
Java 11 |
TESTS |
9 |
265 |
23859200 |
|
800 |
127417656 |
amireripmav786 |
A |
Aug. 30, 2021, 5:08 a.m. |
OK |
Java 11 |
TESTS |
9 |
280 |
23859200 |
|
800 |
127398639 |
omar_mohammed |
A |
Aug. 29, 2021, 7:05 p.m. |
OK |
Java 8 |
TESTS |
9 |
109 |
20480000 |
|
800 |
127396050 |
gagan_6730 |
A |
Aug. 29, 2021, 6:24 p.m. |
OK |
Java 8 |
TESTS |
9 |
109 |
20480000 |
|
800 |
127404078 |
Piyushnagpal80 |
A |
Aug. 29, 2021, 9:36 p.m. |
OK |
Java 8 |
TESTS |
9 |
124 |
20480000 |
|
800 |
127395179 |
gssakash |
A |
Aug. 29, 2021, 6:13 p.m. |
OK |
Java 8 |
TESTS |
9 |
124 |
20480000 |
|
800 |
127412621 |
less_ordinary |
A |
Aug. 30, 2021, 3:14 a.m. |
OK |
Java 8 |
TESTS |
9 |
124 |
20480000 |
|
800 |
127394924 |
amit_roy |
A |
Aug. 29, 2021, 6:11 p.m. |
OK |
Java 8 |
TESTS |
9 |
156 |
20480000 |
|
800 |
127380926 |
GdMstBt |
A |
Aug. 29, 2021, 4:29 p.m. |
OK |
Java 8 |
TESTS |
9 |
171 |
21196800 |
|
800 |
127380123 |
joshi_nitant |
A |
Aug. 29, 2021, 4:26 p.m. |
OK |
Java 8 |
TESTS |
9 |
187 |
20480000 |
|
800 |
127399124 |
yashpandey73 |
A |
Aug. 29, 2021, 7:15 p.m. |
OK |
Java 8 |
TESTS |
9 |
187 |
20480000 |
|
800 |
127409925 |
devanshverma5 |
A |
Aug. 30, 2021, 2 a.m. |
OK |
Java 8 |
TESTS |
9 |
233 |
21299200 |
|
800 |
127395916 |
Krantzy |
A |
Aug. 29, 2021, 6:22 p.m. |
OK |
Kotlin |
TESTS |
9 |
233 |
21811200 |
|
800 |
127393834 |
Dev.Zaki |
A |
Aug. 29, 2021, 6:03 p.m. |
OK |
Kotlin |
TESTS |
9 |
264 |
21401600 |
|
800 |
127418987 |
Jonathan_Chang |
A |
Aug. 30, 2021, 5:35 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
46 |
3788800 |
|
800 |
127407928 |
nilikuo |
A |
Aug. 30, 2021, 12:44 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
46 |
4505600 |
|
800 |
127410527 |
adasanvin12345 |
A |
Aug. 30, 2021, 2:19 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
61 |
3788800 |
|
800 |
127405558 |
tolmachch |
A |
Aug. 29, 2021, 10:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127417874 |
momenahmed10 |
A |
Aug. 30, 2021, 5:13 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127413552 |
_Rimjhim_36 |
A |
Aug. 30, 2021, 3:38 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127411791 |
huy27201 |
A |
Aug. 30, 2021, 2:53 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127407163 |
Soul_Full_Of_Thunder |
A |
Aug. 30, 2021, 12:08 a.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127402859 |
samnext9 |
A |
Aug. 29, 2021, 8:54 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127385819 |
19H51A05M3 |
A |
Aug. 29, 2021, 4:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
9 |
77 |
3788800 |
|
800 |
127395128 |
zoro500 |
A |
Aug. 29, 2021, 6:13 p.m. |
OK |
.NET Core C# |
TESTS |
9 |
140 |
13209600 |
|
800 |
127419237 |
sgyuri |
A |
Aug. 30, 2021, 5:40 a.m. |
OK |
.NET Core C# |
TESTS |
9 |
140 |
14438400 |
|
800 |
127405428 |
guanghechen |
A |
Aug. 29, 2021, 10:32 p.m. |
OK |
Node.js |
TESTS |
9 |
124 |
35020800 |
|
800 |
127394292 |
tryingit |
A |
Aug. 29, 2021, 6:06 p.m. |
OK |
Node.js |
TESTS |
9 |
249 |
18534400 |
|
800 |
127395486 |
SSCoding123 |
A |
Aug. 29, 2021, 6:17 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
155 |
24780800 |
|
800 |
127414139 |
jaehyunp312 |
A |
Aug. 30, 2021, 3:50 a.m. |
OK |
PyPy 3 |
TESTS |
9 |
155 |
25600000 |
|
800 |
127398957 |
legend.ary_as |
A |
Aug. 29, 2021, 7:12 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
156 |
24166400 |
|
800 |
127417468 |
__Broly__ |
A |
Aug. 30, 2021, 5:04 a.m. |
OK |
PyPy 3 |
TESTS |
9 |
156 |
24268800 |
|
800 |
127406564 |
wo0mbat |
A |
Aug. 29, 2021, 11:32 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
170 |
26931200 |
|
800 |
127393970 |
Het_Fadia |
A |
Aug. 29, 2021, 6:04 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
171 |
25088000 |
|
800 |
127407061 |
Liberator187 |
A |
Aug. 30, 2021, 12:02 a.m. |
OK |
PyPy 3 |
TESTS |
9 |
171 |
26828800 |
|
800 |
127404853 |
thhsu |
A |
Aug. 29, 2021, 10:05 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
186 |
25292800 |
|
800 |
127394394 |
Bad_day_toCode |
A |
Aug. 29, 2021, 6:06 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
187 |
27955200 |
|
800 |
127406288 |
BobChuckyJoe |
A |
Aug. 29, 2021, 11:16 p.m. |
OK |
PyPy 3 |
TESTS |
9 |
280 |
26419200 |
|
800 |
127416525 |
behindyou |
A |
Aug. 30, 2021, 4:44 a.m. |
OK |
Python 3 |
TESTS |
9 |
93 |
7065600 |
|
800 |
127385186 |
alex_step |
A |
Aug. 29, 2021, 4:45 p.m. |
OK |
Python 3 |
TESTS |
9 |
93 |
7475200 |
|
800 |
127413048 |
puffc0rn |
A |
Aug. 30, 2021, 3:25 a.m. |
OK |
Python 3 |
TESTS |
9 |
93 |
7782400 |
|
800 |
127417030 |
Bambam_Shivam |
A |
Aug. 30, 2021, 4:55 a.m. |
OK |
Python 3 |
TESTS |
9 |
108 |
7782400 |
|
800 |
127396977 |
har_myrmidian |
A |
Aug. 29, 2021, 6:36 p.m. |
OK |
Python 3 |
TESTS |
9 |
139 |
6963200 |
|
800 |
127394244 |
alank_002 |
A |
Aug. 29, 2021, 6:05 p.m. |
OK |
Python 3 |
TESTS |
9 |
140 |
6758400 |
|
800 |
127395185 |
Andaloo |
A |
Aug. 29, 2021, 6:13 p.m. |
OK |
Python 3 |
TESTS |
9 |
140 |
6758400 |
|
800 |
127417247 |
jacksparrow_9604 |
A |
Aug. 30, 2021, 5 a.m. |
OK |
Python 3 |
TESTS |
9 |
140 |
6758400 |
|
800 |
127413962 |
andre159 |
A |
Aug. 30, 2021, 3:47 a.m. |
OK |
Python 3 |
TESTS |
9 |
140 |
6758400 |
|
800 |
127395886 |
sh1194 |
A |
Aug. 29, 2021, 6:21 p.m. |
OK |
Python 3 |
TESTS |
9 |
140 |
6758400 |
|
800 |
remove filters
Back to search problems