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"Not long ago, Egor learned about the Euclidean algorithm for finding the greatest common divisor of two numbers. The greatest common divisor of two numbers a and b is the largest number that divides both a and b without leaving a remainder. With this knowledge, Egor can solve a problem that he once couldn't. Vasily has a grid with n rows and m columns, and the integer {a_i}_j is located at the intersection of the i -th row and the j -th column. Egor wants to go from the top left corner (at the intersection of the first row and the first column) to the bottom right corner (at the intersection of the last row and the last column) and find the greatest common divisor of all the numbers along the path. He is only allowed to move down and to the right. Egor has written down several paths and obtained different GCD values. He became interested in finding the maximum possible GCD. Unfortunately, Egor is tired of calculating GCDs, so he asks for your help in finding the maximum GCD of the integers along the path from the top left corner to the bottom right corner of the grid. The first line contains an integer t ( 1 <= t <= {10}^{4} ) -- the number of test cases. The first line of each test case contains two integers n and m ( 1 <= n, m <= 100 ) -- the number of rows and columns of the grid. Then, there are n lines, where the i -th line contains m integers (1 <= a_{i,j} <= {10}^{6} ) -- the integers written in the i -th row and the j -th column of the grid. It is guaranteed that the sum of n cdot m does not exceed 2 cdot {10}^{5} over all test cases. For each test case, output the maximum possible GCD along the path from the top left cell to the bottom right cell in a separate line. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
255797016 |
EKGMA |
G |
April 8, 2024, 11:29 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
374 |
204800 |
|
|
255788855 |
the_dragon_emperor |
G |
April 8, 2024, 9:10 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
390 |
102400 |
|
|
255802673 |
fzcdream |
G |
April 9, 2024, 1:16 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
406 |
102400 |
|
|
255797366 |
moon100_fan |
G |
April 8, 2024, 11:35 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
593 |
204800 |
|
|
255776612 |
Vannn168 |
G |
April 8, 2024, 6:57 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
718 |
102400 |
|
|
255782022 |
Komal_2021 |
G |
April 8, 2024, 7:51 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
749 |
2867200 |
|
|
255772575 |
Hakarishirenai |
G |
April 8, 2024, 6:24 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
968 |
102400 |
|
|
255766808 |
LucaT123 |
G |
April 8, 2024, 5:42 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
25 |
1015 |
204800 |
|
|
255800392 |
Hups |
G |
April 9, 2024, 12:36 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1061 |
307200 |
|
|
255815483 |
Tong_Yuxin |
G |
April 9, 2024, 4:15 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1077 |
102400 |
|
|
255777691 |
abab1729 |
G |
April 8, 2024, 7:07 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
202 |
307200 |
|
|
255773643 |
ProcrastinatorAdEldonia |
G |
April 8, 2024, 6:32 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
218 |
15155200 |
|
|
255767730 |
Mr_Sa3dola |
G |
April 8, 2024, 5:48 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
234 |
102400 |
|
|
255770667 |
Kerolloos |
G |
April 8, 2024, 6:09 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
264 |
102400 |
|
|
255802891 |
hachi125 |
G |
April 9, 2024, 1:20 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
265 |
102400 |
|
|
255813396 |
CuteJerry |
G |
April 9, 2024, 3:49 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
265 |
204800 |
|
|
255772315 |
ahmedsassi372 |
G |
April 8, 2024, 6:22 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
296 |
0 |
|
|
255782597 |
pandeyGRocks |
G |
April 8, 2024, 7:57 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
296 |
102400 |
|
|
255798594 |
IcarusII |
G |
April 9, 2024, 12:03 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
374 |
102400 |
|
|
255773126 |
noobcoder696969 |
G |
April 8, 2024, 6:28 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
25 |
374 |
102400 |
|
|
255772318 |
NotFound |
G |
April 8, 2024, 6:22 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
233 |
102400 |
|
|
255778494 |
AL70SSAIN |
G |
April 8, 2024, 7:15 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
234 |
102400 |
|
|
255781481 |
BERNARD |
G |
April 8, 2024, 7:46 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
265 |
102400 |
|
|
255778296 |
Hitham |
G |
April 8, 2024, 7:13 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
25 |
265 |
204800 |
|
|
255814438 |
qiqinanzijing |
G |
April 9, 2024, 4:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
280 |
102400 |
|
|
255816096 |
Khaled_Al_Awad |
G |
April 9, 2024, 4:23 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
296 |
204800 |
|
|
255809270 |
xjy_magic |
G |
April 9, 2024, 2:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
343 |
102400 |
|
|
255803579 |
NekoYellow |
G |
April 9, 2024, 1:31 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
343 |
102400 |
|
|
255791509 |
Abraxos |
G |
April 8, 2024, 9:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
359 |
102400 |
|
|
255806224 |
Rainer1116 |
G |
April 9, 2024, 2:15 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
374 |
102400 |
|
|
255782653 |
lorenzotinfena |
G |
April 8, 2024, 7:58 p.m. |
OK |
Go |
TESTS |
25 |
937 |
5222400 |
|
|
255781160 |
lorenzotinfena |
G |
April 8, 2024, 7:42 p.m. |
OK |
Go |
TESTS |
25 |
1156 |
5222400 |
|
|
255804013 |
The_Hallak |
G |
April 9, 2024, 1:38 a.m. |
OK |
Go |
TESTS |
36 |
1296 |
4198400 |
|
|
255780939 |
lorenzotinfena |
G |
April 8, 2024, 7:40 p.m. |
OK |
Go |
TESTS |
25 |
1686 |
5222400 |
|
|
255815405 |
newfolder2022 |
G |
April 9, 2024, 4:14 a.m. |
OK |
Java 21 |
TESTS |
36 |
749 |
921600 |
|
|
255770858 |
new2ac |
G |
April 8, 2024, 6:10 p.m. |
OK |
Java 21 |
TESTS |
25 |
1218 |
614400 |
|
|
255796741 |
GaleStarr |
G |
April 8, 2024, 11:24 p.m. |
OK |
Java 21 |
TESTS |
36 |
1374 |
1024000 |
|
|
255793212 |
BlizGale |
G |
April 8, 2024, 10:16 p.m. |
OK |
Java 21 |
TESTS |
36 |
1375 |
1126400 |
|
|
255793147 |
GaleStarr |
G |
April 8, 2024, 10:15 p.m. |
OK |
Java 21 |
TESTS |
36 |
1375 |
1126400 |
|
|
255814766 |
newfolder2022 |
G |
April 9, 2024, 4:05 a.m. |
OK |
Java 21 |
TESTS |
36 |
2124 |
1228800 |
|
|
255805570 |
Zhanzhe_Lee |
G |
April 9, 2024, 2:06 a.m. |
OK |
Java 21 |
TESTS |
36 |
2124 |
1228800 |
|
|
255798817 |
profchi |
G |
April 9, 2024, 12:07 a.m. |
OK |
Java 21 |
TESTS |
36 |
2280 |
512000 |
|
|
255821187 |
dzhi |
G |
April 9, 2024, 5:20 a.m. |
OK |
Java 21 |
TESTS |
53 |
2358 |
1536000 |
|
|
255771685 |
wat2 |
G |
April 8, 2024, 6:17 p.m. |
OK |
Java 8 |
TESTS |
25 |
1092 |
0 |
|
|
255815222 |
newfolder2022 |
G |
April 9, 2024, 4:12 a.m. |
OK |
Java 8 |
TESTS |
36 |
1093 |
0 |
|
|
255772886 |
Yousef_Badr |
G |
April 8, 2024, 6:26 p.m. |
OK |
Java 8 |
TESTS |
25 |
1109 |
0 |
|
|
255815247 |
newfolder2022 |
G |
April 9, 2024, 4:12 a.m. |
OK |
Java 8 |
TESTS |
36 |
1155 |
0 |
|
|
255791257 |
vatsal_04 |
G |
April 8, 2024, 9:44 p.m. |
OK |
Java 8 |
TESTS |
36 |
1296 |
7475200 |
|
|
255815176 |
newfolder2022 |
G |
April 9, 2024, 4:11 a.m. |
OK |
Java 8 |
TESTS |
36 |
2171 |
0 |
|
|
255813697 |
newfolder2022 |
G |
April 9, 2024, 3:52 a.m. |
OK |
Java 8 |
TESTS |
36 |
2187 |
0 |
|
|
255809008 |
faresbadr316 |
G |
April 9, 2024, 2:53 a.m. |
OK |
Java 8 |
TESTS |
36 |
2311 |
0 |
|
|
255813561 |
newfolder2022 |
G |
April 9, 2024, 3:50 a.m. |
OK |
Java 8 |
TESTS |
36 |
2358 |
0 |
|
|
255813761 |
newfolder2022 |
G |
April 9, 2024, 3:53 a.m. |
OK |
Java 8 |
TESTS |
36 |
2374 |
0 |
|
|
255802515 |
YMSeah |
G |
April 9, 2024, 1:14 a.m. |
OK |
PyPy 3 |
TESTS |
36 |
2796 |
9523200 |
|
|
255772847 |
the_last_smilodon |
G |
April 8, 2024, 6:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
999 |
22118400 |
|
|
255783650 |
the_last_smilodon |
G |
April 8, 2024, 8:09 p.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1077 |
10035200 |
|
|
255783835 |
the_last_smilodon |
G |
April 8, 2024, 8:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1155 |
10137600 |
|
|
255807330 |
Little_Sheep_Yawn |
G |
April 9, 2024, 2:32 a.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
1515 |
11059200 |
|
|
255808627 |
Little_Sheep_Yawn |
G |
April 9, 2024, 2:48 a.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
1530 |
37888000 |
|
|
255811023 |
JinYuManTang |
G |
April 9, 2024, 3:18 a.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
2843 |
11059200 |
|
|
255774036 |
vstiff |
G |
April 8, 2024, 6:35 p.m. |
OK |
Rust 2021 |
TESTS |
25 |
233 |
102400 |
|
|
remove filters
Back to search problems