Codeforces Round 1028 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2115 Codeforces Round 1028 (Div. 1) FINISHED False 7200 27703523 May 31, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 14807 ) A Gellyfish and Flaming Peony PROGRAMMING brute force constructive algorithms dp greedy math number theory shortest paths

Gellyfish hates math problems, but she has to finish her math homework: Gellyfish is given an array of (n) positive integers (a_1, a_2, \ldots, a_n). She needs to do the following two-step operation until all elements of (a) are equal: Select two indexes (i), (j) satisfying (1 \leq i, j \leq n) and (i \neq j). Replace (a_i) with (\gcd(a_i, a_j)). Now, Gellyfish asks you for the minimum number of operations to achieve her goal. It can be proven that Gellyfish can always achieve her goal. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 5000)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \leq n \leq 5000)) — the length of the array. The second line of each test case contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \leq a_i \leq 5000)) — the elements of the array. It is guaranteed that the sum of (n) over all test cases does not exceed (5000). For each test case, output a single integer — the minimum number of operations to achieve her goal. In the first test case, the following is a way that minimizes the number of operations: Choose (i = 3) and (j=2) and replace (a_3) with (\gcd(a_3,a_2) = \gcd(30, 20) = 10), then (a) becomes (12, 20, 10). Choose (i=1) and (j=3) and replace (a_1) with (\gcd(a_1,a_3) = \gcd(12, 10) = 2), then (a) becomes (2, 20, 10). Choose (i=2) and (j=1) and replace (a_2) with (\gcd(a_2,a_1) = \gcd(20, 2) = 2), then (a) becomes (2, 2, 10). Choose (i=3) and (j=1) and replace (a_3) with (\gcd(a_3,a_1) = \gcd(10, 2) = 2), then (a) becomes (2, 2, 2).

Tutorials

Codeforces Round 1028 (Div.1, Div.2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
322215764 mban259 A May 31, 2025, 2:57 p.m. OK C# 10 TESTS 15 1265 7987200
322248091 Lawali A May 31, 2025, 3:29 p.m. OK C++17 (GCC 7-32) TESTS 15 61 102400
322241507 Nahian9696 A May 31, 2025, 3:22 p.m. OK C++17 (GCC 7-32) TESTS 15 62 102400
322243537 SPatrik A May 31, 2025, 3:24 p.m. OK C++17 (GCC 7-32) TESTS 15 140 0
322219174 harshal02 A May 31, 2025, 3 p.m. OK C++17 (GCC 7-32) TESTS 15 140 102400
322217559 Little_CarT A May 31, 2025, 2:58 p.m. OK C++17 (GCC 7-32) TESTS 15 140 102400
322224760 lostkeytoreach A May 31, 2025, 3:05 p.m. OK C++17 (GCC 7-32) TESTS 15 171 0
322205364 Morphed A May 31, 2025, 2:48 p.m. OK C++17 (GCC 7-32) TESTS 15 171 102400
322210467 SamuelTull A May 31, 2025, 2:52 p.m. OK C++17 (GCC 7-32) TESTS 15 202 102400
322203335 Jayanthdvv A May 31, 2025, 2:46 p.m. OK C++17 (GCC 7-32) TESTS 15 202 102400
322243284 Wielomian A May 31, 2025, 3:24 p.m. OK C++17 (GCC 7-32) TESTS 15 202 96768000
322223845 justin_zed A May 31, 2025, 3:04 p.m. OK C++20 (GCC 13-64) TESTS 15 46 102400
322329305 Dominater069 A June 1, 2025, 1:31 a.m. OK C++20 (GCC 13-64) TESTS 23 77 102400
322224603 DaNeK0201 A May 31, 2025, 3:04 p.m. OK C++20 (GCC 13-64) TESTS 15 93 102400
322204073 siganai A May 31, 2025, 2:47 p.m. OK C++20 (GCC 13-64) TESTS 15 93 102400
322231369 SongC A May 31, 2025, 3:11 p.m. OK C++20 (GCC 13-64) TESTS 15 108 102400
322219570 oqmsac A May 31, 2025, 3 p.m. OK C++20 (GCC 13-64) TESTS 15 109 32153600
322303145 Taibo A May 31, 2025, 6:02 p.m. OK C++20 (GCC 13-64) TESTS 15 124 201420800
322239641 langdog A May 31, 2025, 3:20 p.m. OK C++20 (GCC 13-64) TESTS 15 124 201420800
322300683 icube A May 31, 2025, 5:49 p.m. OK C++20 (GCC 13-64) TESTS 15 155 102400
322257878 rikel_pik A May 31, 2025, 3:41 p.m. OK C++20 (GCC 13-64) TESTS 15 155 102400
322248648 Pan_H A May 31, 2025, 3:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
322305455 m1une A May 31, 2025, 6:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 102400
322207089 ecnerwala A May 31, 2025, 2:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 61 0
322309277 aayushdalal A May 31, 2025, 6:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 61 102400
322220011 silverstorm A May 31, 2025, 3 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 62 0
322301865 m1une A May 31, 2025, 5:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 62 102400
322309319 _El_Patron A May 31, 2025, 6:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 77 102400
322300252 MR.Kaka87 A May 31, 2025, 5:47 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 78 102400
322330499 silverstorm A June 1, 2025, 2:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 93 102400
322245893 _WD_ A May 31, 2025, 3:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 125 8089600
322217340 Gassa A May 31, 2025, 2:58 p.m. OK D TESTS 15 1656 154726400
322208901 pengin_2000 A May 31, 2025, 2:51 p.m. OK GNU C11 TESTS 15 1515 204800
322202570 Dominion948 A May 31, 2025, 2:46 p.m. OK Go TESTS 15 1124 716800
322340243 Kohl A June 1, 2025, 4:32 a.m. OK Java 21 TESTS 23 1108 921600
322239671 sahasrad A May 31, 2025, 3:20 p.m. OK Java 21 TESTS 15 1484 512000
322321455 sahasrad A May 31, 2025, 9:24 p.m. OK Java 21 TESTS 22 1484 614400
322321783 Pranav_45 A May 31, 2025, 9:30 p.m. OK Java 8 TESTS 22 983 0
322221626 omdeshmukh1906 A May 31, 2025, 3:02 p.m. OK Java 8 TESTS 15 1046 0
322311570 Akshatgupta069_069 A May 31, 2025, 7:04 p.m. OK Java 8 TESTS 17 1202 0
322204609 jueviolegrace A May 31, 2025, 2:47 p.m. OK Java 8 TESTS 15 1546 0
322315513 kasiru_69 A May 31, 2025, 7:49 p.m. OK Java 8 TESTS 22 1686 0
322320741 darnley A May 31, 2025, 9:09 p.m. OK Kotlin 1.9 TESTS 22 1343 2048000
322198959 darnley A May 31, 2025, 2:43 p.m. OK Kotlin 1.9 TESTS 15 1436 2048000
322208547 a2bailey A May 31, 2025, 2:50 p.m. OK PyPy 3 TESTS 15 1733 11264000
322327486 smilences A June 1, 2025, 12:30 a.m. OK PyPy 3-64 TESTS 23 218 4710400
322214015 hxu10 A May 31, 2025, 2:55 p.m. OK PyPy 3-64 TESTS 15 281 3072000
322254801 harurun4635 A May 31, 2025, 3:37 p.m. OK PyPy 3-64 TESTS 15 343 5529600
322228966 shade34 A May 31, 2025, 3:09 p.m. OK PyPy 3-64 TESTS 15 436 5120000
322207677 Ayis137 A May 31, 2025, 2:50 p.m. OK PyPy 3-64 TESTS 15 764 5939200
322301557 samchen123 A May 31, 2025, 5:53 p.m. OK PyPy 3-64 TESTS 15 781 3686400
322304111 samchen123 A May 31, 2025, 6:07 p.m. OK PyPy 3-64 TESTS 15 842 9113600
322215722 Kira_Dev A May 31, 2025, 2:56 p.m. OK PyPy 3-64 TESTS 15 859 3481600
322213531 Maruzensky A May 31, 2025, 2:55 p.m. OK PyPy 3-64 TESTS 15 937 8806400
322213057 dyppp A May 31, 2025, 2:54 p.m. OK PyPy 3-64 TESTS 15 984 223232000
322332771 darkkcyan A June 1, 2025, 2:45 a.m. OK Rust 2021 TESTS 23 702 201216000
322203064 DanielAnker A May 31, 2025, 2:46 p.m. OK Rust 2021 TESTS 15 1092 102400
322245352 darkkcyan A May 31, 2025, 3:26 p.m. OK Rust 2021 TESTS 15 1905 201728000

remove filters

Back to search problems