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'This is an interactive problem. There is a positive integer 1 <= x <= 10^9 that you have to guess. In one query you can choose two positive integers a neq b . As an answer to this query you will get gcd(x + a, x + b) , where gcd(n, m) is the greatest common divisor of the numbers n and m . To guess one hidden number x you are allowed to make no more than 30 queries. The first line of input contains a single integer t ( 1 <= t <= 1000 ) denoting the number of test cases. The integer x that you have to guess satisfies the constraints: ( 1 <= x <= 10^9 ). The hidden number x is fixed before the start of the interaction and does not depend on your queries. To guess each x you can make no more than 30 queries in the following way: For this query you will get gcd(x + a, x + b) . When you know x , print a single line in the following format. After that continue to solve the next test case. If you ask more than 30 queries for one x or make an invalid query, the interactor will terminate immediately and your program will receive verdict Wrong Answer. After printing each query do not forget to output end of line and flush the output buffer. Otherwise, you will get the Idleness limit exceeded verdict. To do flush use: Hacks To use hacks, use the following format of tests: The first line should contain a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The first and only line of each test case should contain a single integer x ( 1 <= x <= 10^9 ) denoting the integer x that should be guessed. The first hidden number is 4 , that 's why the answers for the queries are: "? 1 2" -- gcd(4 + 1, 4 + 2) = gcd(5, 6) = 1 . "? 12 4" -- gcd(4 + 12, 4 + 4) = gcd(16, 8) = 8 . The second hidden number is 10^9 , that 's why the answer for the query is: "? 2000000000 1999999999" -- gcd(3 cdot '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
153066084 |
rainboy |
D |
April 8, 2022, 4:16 p.m. |
OK |
GNU C11 |
TESTS |
31 |
420 |
0 |
|
|
153116126 |
Max_Calincu |
D |
April 9, 2022, 6:01 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
186 |
0 |
|
|
153111749 |
Write_Hape_Code |
D |
April 9, 2022, 4:58 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
202 |
5017600 |
|
|
153114904 |
Write_Hape_Code |
D |
April 9, 2022, 5:45 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
233 |
0 |
|
|
153106808 |
Yang_Rick |
D |
April 9, 2022, 3:15 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
264 |
0 |
|
|
153067081 |
t98slider |
D |
April 8, 2022, 4:19 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
264 |
409600 |
|
|
153067756 |
RBpencil |
D |
April 8, 2022, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
31 |
265 |
0 |
|
|
153111646 |
Ecrade_ |
D |
April 9, 2022, 4:55 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
280 |
0 |
|
|
153108965 |
Rice_porridge |
D |
April 9, 2022, 4:02 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
280 |
0 |
|
|
153105996 |
Acestar |
D |
April 9, 2022, 2:55 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
280 |
0 |
|
|
153105980 |
Dark_Stalker |
D |
April 9, 2022, 2:55 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
280 |
0 |
|
|
153100844 |
krit3379 |
D |
April 9, 2022, 12:25 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
171 |
0 |
|
|
153091850 |
DiegoGarcia |
D |
April 8, 2022, 8:42 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
187 |
0 |
|
|
153075897 |
The_Hallak |
D |
April 8, 2022, 5:11 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
187 |
0 |
|
|
153071276 |
tarush0605 |
D |
April 8, 2022, 4:31 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
187 |
0 |
|
|
153086925 |
YahiaSherif |
D |
April 8, 2022, 7:21 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
202 |
0 |
|
|
153067919 |
manh9203 |
D |
April 8, 2022, 4:21 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
218 |
0 |
|
|
153074607 |
danny0122 |
D |
April 8, 2022, 5:03 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
218 |
6041600 |
|
|
153100374 |
Inari_ |
D |
April 9, 2022, 12:13 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
233 |
0 |
|
|
153075668 |
danny0122 |
D |
April 8, 2022, 5:10 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
233 |
6041600 |
|
|
153075440 |
danny0122 |
D |
April 8, 2022, 5:08 p.m. |
OK |
GNU C++17 |
TESTS |
31 |
234 |
6041600 |
|
|
153083854 |
atanughosh01 |
D |
April 8, 2022, 6:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
171 |
0 |
|
|
153083153 |
atanughosh01 |
D |
April 8, 2022, 6:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
187 |
0 |
|
|
153083566 |
atanughosh01 |
D |
April 8, 2022, 6:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
202 |
0 |
|
|
153074059 |
artcosec |
D |
April 8, 2022, 5:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
218 |
0 |
|
|
153109129 |
Sion_y |
D |
April 9, 2022, 4:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
233 |
0 |
|
|
153082575 |
mknayam |
D |
April 8, 2022, 6:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
248 |
0 |
|
|
153080896 |
soonmoo |
D |
April 8, 2022, 5:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
248 |
0 |
|
|
153105893 |
tommyjiang |
D |
April 9, 2022, 2:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
249 |
0 |
|
|
153072523 |
Pedestrian1 |
D |
April 8, 2022, 4:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
249 |
819200 |
|
|
153106798 |
retiredd |
D |
April 9, 2022, 3:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
264 |
0 |
|
|
153072961 |
yash_daga |
D |
April 8, 2022, 4:34 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
171 |
0 |
|
|
153086655 |
Hiranmoy |
D |
April 8, 2022, 7:17 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
187 |
0 |
|
|
153076209 |
spongebobsquareroot |
D |
April 8, 2022, 5:13 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
218 |
0 |
|
|
153090902 |
cosenza |
D |
April 8, 2022, 8:26 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
233 |
0 |
|
|
153101043 |
apoorv_me |
D |
April 9, 2022, 12:31 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
249 |
0 |
|
|
153081776 |
Theo830 |
D |
April 8, 2022, 6:08 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
249 |
0 |
|
|
153065258 |
shivaram_22 |
D |
April 8, 2022, 4:13 p.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
249 |
0 |
|
|
153115122 |
aryan1602 |
D |
April 9, 2022, 5:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
264 |
0 |
|
|
153106539 |
Youling_wang |
D |
April 9, 2022, 3:08 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
264 |
0 |
|
|
153101799 |
Alan233 |
D |
April 9, 2022, 12:53 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
264 |
0 |
|
|
153076191 |
santjuan2022 |
D |
April 8, 2022, 5:13 p.m. |
OK |
Java 11 |
TESTS |
31 |
982 |
0 |
|
|
153090672 |
soumit915 |
D |
April 8, 2022, 8:22 p.m. |
OK |
Java 11 |
TESTS |
31 |
1044 |
0 |
|
|
153090724 |
soumit915 |
D |
April 8, 2022, 8:23 p.m. |
OK |
Java 11 |
TESTS |
31 |
1091 |
0 |
|
|
153083572 |
eshan18.09 |
D |
April 8, 2022, 6:30 p.m. |
OK |
Java 11 |
TESTS |
31 |
1294 |
0 |
|
|
153078468 |
bhatt.eshan1736 |
D |
April 8, 2022, 5:33 p.m. |
OK |
Java 11 |
TESTS |
31 |
1294 |
0 |
|
|
153075771 |
Yuki_B |
D |
April 8, 2022, 5:10 p.m. |
OK |
Java 11 |
TESTS |
31 |
1325 |
204800 |
|
|
153071836 |
nebula6611 |
D |
April 8, 2022, 4:32 p.m. |
OK |
Java 11 |
TESTS |
31 |
1372 |
0 |
|
|
153083758 |
Plums |
D |
April 8, 2022, 6:33 p.m. |
OK |
Java 11 |
TESTS |
31 |
1404 |
0 |
|
|
153068683 |
lewandowski_9 |
D |
April 8, 2022, 4:24 p.m. |
OK |
Java 11 |
TESTS |
31 |
1544 |
204800 |
|
|
153069893 |
Apfeloxid |
D |
April 8, 2022, 4:27 p.m. |
OK |
Java 11 |
TESTS |
31 |
1622 |
204800 |
|
|
153075393 |
Ghost_Fox_Sledgehammer |
D |
April 8, 2022, 5:08 p.m. |
OK |
Java 8 |
TESTS |
31 |
904 |
0 |
|
|
153074040 |
aggarwalanshul01 |
D |
April 8, 2022, 5:01 p.m. |
OK |
Java 8 |
TESTS |
31 |
1153 |
0 |
|
|
153069459 |
ak_ankit |
D |
April 8, 2022, 4:26 p.m. |
OK |
Java 8 |
TESTS |
31 |
1310 |
0 |
|
|
153068712 |
Tlatoani |
D |
April 8, 2022, 4:24 p.m. |
OK |
Kotlin 1.4 |
TESTS |
31 |
624 |
0 |
|
|
153100595 |
meinego |
D |
April 9, 2022, 12:19 a.m. |
OK |
Kotlin 1.4 |
TESTS |
31 |
1107 |
0 |
|
|
153069822 |
xjcl |
D |
April 8, 2022, 4:27 p.m. |
OK |
Kotlin 1.5 |
TESTS |
31 |
826 |
0 |
|
|
153068705 |
ktropin |
D |
April 8, 2022, 4:24 p.m. |
OK |
Mono C# |
TESTS |
31 |
545 |
3072000 |
|
|
153087292 |
KseniaShk |
D |
April 8, 2022, 7:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
389 |
0 |
|
|
153111063 |
zhoultt |
D |
April 9, 2022, 4:45 a.m. |
OK |
MS C++ 2017 |
TESTS |
31 |
405 |
0 |
|
|
153068509 |
Tdyx |
D |
April 8, 2022, 4:23 p.m. |
OK |
.NET Core C# |
TESTS |
31 |
390 |
3993600 |
|
|
153080760 |
acorn11 |
D |
April 8, 2022, 5:56 p.m. |
OK |
PyPy 2 |
TESTS |
31 |
686 |
1331200 |
|
|
153099143 |
1_2_3_4_5_9 |
D |
April 8, 2022, 11:40 p.m. |
OK |
PyPy 2 |
TESTS |
31 |
686 |
9625600 |
|
|
153080459 |
immike |
D |
April 8, 2022, 5:53 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
795 |
6758400 |
|
|
153112620 |
legend.ary_as |
D |
April 9, 2022, 5:12 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
873 |
7680000 |
|
|
153076159 |
codicon |
D |
April 8, 2022, 5:13 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
982 |
3788800 |
|
|
153078648 |
Vermeil |
D |
April 8, 2022, 5:34 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1138 |
5222400 |
|
|
153065812 |
_deva_ |
D |
April 8, 2022, 4:15 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1138 |
10137600 |
|
|
153108981 |
mnkqc |
D |
April 9, 2022, 4:02 a.m. |
OK |
PyPy 3 |
TESTS |
31 |
1169 |
4608000 |
|
|
153089491 |
r_j_sangram |
D |
April 8, 2022, 8:03 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1279 |
10137600 |
|
|
153086191 |
shehebe |
D |
April 8, 2022, 7:09 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1310 |
5734400 |
|
|
153075396 |
Amiy_Tiwari |
D |
April 8, 2022, 5:08 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1310 |
8192000 |
|
|
153068741 |
zouyu9631 |
D |
April 8, 2022, 4:24 p.m. |
OK |
PyPy 3 |
TESTS |
31 |
1388 |
8089600 |
|
|
153074569 |
Mashin_larner |
D |
April 8, 2022, 5:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
873 |
9523200 |
|
|
153075037 |
sakshatmali |
D |
April 8, 2022, 5:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
919 |
9420800 |
|
|
153099153 |
1_2_3_4_5_9 |
D |
April 8, 2022, 11:40 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1091 |
15360000 |
|
|
153083122 |
_icy_ |
D |
April 8, 2022, 6:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1185 |
6246400 |
|
|
153074357 |
Neothehero |
D |
April 8, 2022, 5:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1232 |
9318400 |
|
|
153078722 |
turkids |
D |
April 8, 2022, 5:35 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1247 |
7782400 |
|
|
153071892 |
Neothehero |
D |
April 8, 2022, 4:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1263 |
9318400 |
|
|
153075985 |
huangxw |
D |
April 8, 2022, 5:12 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1279 |
10137600 |
|
|
153071982 |
ctt312000 |
D |
April 8, 2022, 4:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1294 |
6860800 |
|
|
153086692 |
dean.menezes |
D |
April 8, 2022, 7:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
1294 |
9932800 |
|
|
153078675 |
Vermeil |
D |
April 8, 2022, 5:35 p.m. |
OK |
Python 3 |
TESTS |
31 |
966 |
307200 |
|
|
153082701 |
robostac |
D |
April 8, 2022, 6:19 p.m. |
OK |
Rust 2021 |
TESTS |
31 |
467 |
0 |
|
|
153068580 |
Normie28 |
D |
April 8, 2022, 4:23 p.m. |
OK |
Rust 2021 |
TESTS |
31 |
483 |
0 |
|
|
remove filters
Back to search problems