Codeforces Round 1118 (Div. 2)

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
2258 Codeforces Round 1118 (Div. 2) FINISHED False 7200 141884 Aug. 29, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 399 ) E DivMEX PROGRAMMING data structures math number theory

You are given an array (a_1, a_2, \ldots, a_n) of positive integers. Let (f(l,r)) for (1 \leq l \leq r \leq n) be the smallest positive integer that doesn't divide (\operatorname{lcm}(a_l, a_{l+1}, \ldots, a_r)). Here, (\operatorname{lcm}) of an array of integers denotes the least common multiple (LCM) of these integers. Determine every positive integer (x) such that there exists a pair of integers ((l,r)) such that (1 \leq l \leq r \leq n) and (f(l,r) = x). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains (n) ((1 \le n \le 2 \cdot 10^5)), denoting the size of the array. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le n)). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output two lines. The first line should contain a single integer (k) — the number of suitable integers (x). The second line should contain (k) integers (x_1 \lt x_2 \lt \ldots \lt x_k), the suitable integers in increasing order. In the first test case, the only ((l,r)) pair is ((1,1)), and (f(1,1) = 2). In the second test case, ((l,r)=(1,1)) yields the set of divisors (\{ 1,2 \}), ((l,r)=(1,2)) yields the set of divisors (\{ 1, 2, 3, 6\}), and ((l,r)=(2,2)) yields the set of divisors (\{ 1, 3 \}). This means (f(1,1)=3), (f(1,2)=4), and (f(2,2)=2). Since no other ((l,r)) pair produces a different (f) value, the answer is (2,3,4). For the last test case, (f(2,2)=2), (f(1,1)=3), and (f(1,5)=5). It can be seen that no other values can be obtained.

Tutorials

Codeforces Round 1118 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
388824351 albertwangwm E Aug. 29, 2026, 4:06 p.m. OK C++17 (GCC 7-32) TESTS 38 171 1024000
388827635 wit777777 E Aug. 29, 2026, 4:15 p.m. OK C++17 (GCC 7-32) TESTS 38 171 22425600
388830189 rayyanrasoolmir E Aug. 29, 2026, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 38 203 5734400
388829780 Tai_The_2.5 E Aug. 29, 2026, 4:22 p.m. OK C++17 (GCC 7-32) TESTS 38 203 47616000
388834195 ranjanjyoti27022006 E Aug. 29, 2026, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 38 218 512000
388832139 wwz_xyz E Aug. 29, 2026, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 38 234 1638400
388829091 1ves E Aug. 29, 2026, 4:20 p.m. OK C++17 (GCC 7-32) TESTS 38 234 27340800
388830224 tapandutta46779 E Aug. 29, 2026, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 38 265 6144000
388836968 a7a7a7a E Aug. 29, 2026, 4:56 p.m. OK C++17 (GCC 7-32) TESTS 38 296 22016000
388825013 Scahispo_ E Aug. 29, 2026, 4:08 p.m. OK C++17 (GCC 7-32) TESTS 38 296 60313600
388833226 rishi_sahu12 E Aug. 29, 2026, 4:31 p.m. OK C++20 (GCC 13-64) TESTS 38 171 19968000
388852684 mingga E Aug. 29, 2026, 7:33 p.m. OK C++20 (GCC 13-64) TESTS 38 187 1024000
388836380 Dark__Seith E Aug. 29, 2026, 4:52 p.m. OK C++20 (GCC 13-64) TESTS 38 203 1638400
388874519 primesarespecial E Aug. 30, 2026, 5:50 a.m. OK C++20 (GCC 13-64) TESTS 38 218 8704000
388844481 deeptanshuyadav4 E Aug. 29, 2026, 6:11 p.m. OK C++20 (GCC 13-64) TESTS 38 234 27443200
388841054 Omar_Mohammad E Aug. 29, 2026, 5:36 p.m. OK C++20 (GCC 13-64) TESTS 38 250 32665600
388837656 SupperX E Aug. 29, 2026, 5:02 p.m. OK C++20 (GCC 13-64) TESTS 38 265 5939200
388833438 thanglieu2 E Aug. 29, 2026, 4:32 p.m. OK C++20 (GCC 13-64) TESTS 38 265 10547200
388839167 White_Daisy E Aug. 29, 2026, 5:17 p.m. OK C++20 (GCC 13-64) TESTS 38 265 30924800
388834251 shobonvip E Aug. 29, 2026, 4:34 p.m. OK C++20 (GCC 13-64) TESTS 38 281 10240000
388825948 Sonu2208 E Aug. 29, 2026, 4:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 125 25088000
388854763 Aa_k E Aug. 29, 2026, 8:09 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 125 54272000
388833733 dzik77 E Aug. 29, 2026, 4:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 156 46899200
388825346 ttamx E Aug. 29, 2026, 4:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 171 31436800
388833686 Nikhil45 E Aug. 29, 2026, 4:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 187 102400
388829782 mini_mini E Aug. 29, 2026, 4:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 203 38400000
388869424 ramumali2002 E Aug. 30, 2026, 4:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 38 203 119808000
388824251 MuoohlAG E Aug. 29, 2026, 4:05 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 218 102400
388834040 Getaway_Car_follower E Aug. 29, 2026, 4:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 218 119808000
388846366 bookcat E Aug. 29, 2026, 6:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 38 234 1433600
388826741 dhruvmig2010 E Aug. 29, 2026, 4:13 p.m. OK GNU C11 TESTS 38 546 34713600
388825387 rainboy E Aug. 29, 2026, 4:09 p.m. OK GNU C11 TESTS 38 578 11776000
388839114 m_husssain E Aug. 29, 2026, 5:16 p.m. OK GNU C11 TESTS 38 609 52633600
388829999 hardiknarang2509 E Aug. 29, 2026, 4:22 p.m. OK Java 21 TESTS 38 328 14233600
388843825 ayeshaleem5033 E Aug. 29, 2026, 6:04 p.m. OK Java 21 TESTS 38 437 1740800
388833764 GrindUntilRed E Aug. 29, 2026, 4:33 p.m. OK Java 21 TESTS 38 562 21094400
388827754 iam_bk E Aug. 29, 2026, 4:16 p.m. OK Java 21 TESTS 38 656 4505600
388839684 pratthu45 E Aug. 29, 2026, 5:22 p.m. OK Java 21 TESTS 38 1187 128614400
388832669 sachin-123 E Aug. 29, 2026, 4:30 p.m. OK Java 21 TESTS 38 1281 819200
388826196 dsarituraj E Aug. 29, 2026, 4:11 p.m. OK Java 21 TESTS 38 1453 39526400
388834234 Subhiks212 E Aug. 29, 2026, 4:34 p.m. OK Java 8 TESTS 38 421 5017600
388827990 CodeLegend1804 E Aug. 29, 2026, 4:16 p.m. OK PyPy 3 TESTS 38 859 43622400
388844461 chocolate_cookie E Aug. 29, 2026, 6:11 p.m. OK PyPy 3-64 TESTS 38 546 91340800
388830428 KaveenKrithik E Aug. 29, 2026, 4:24 p.m. OK PyPy 3-64 TESTS 38 593 37376000
388875114 code.demon E Aug. 30, 2026, 6:01 a.m. OK PyPy 3-64 TESTS 38 671 36249600
388835892 Pulkit_gupta E Aug. 29, 2026, 4:48 p.m. OK PyPy 3-64 TESTS 38 687 36249600
388820916 EliteCoder_77 E Aug. 29, 2026, 3:56 p.m. OK PyPy 3-64 TESTS 38 703 87347200
388830547 iamRishii E Aug. 29, 2026, 4:24 p.m. OK PyPy 3-64 TESTS 38 875 69836800
388833977 genlisa E Aug. 29, 2026, 4:33 p.m. OK PyPy 3-64 TESTS 38 906 99328000
388863573 hxu10 E Aug. 30, 2026, 1:11 a.m. OK PyPy 3-64 TESTS 38 1562 175820800
388823451 meet_kodrani E Aug. 29, 2026, 4:03 p.m. OK PyPy 3-64 TESTS 38 1750 220774400
388827436 sufe06g E Aug. 29, 2026, 4:15 p.m. OK Python 3 TESTS 38 2281 44748800
388820040 hillhill E Aug. 29, 2026, 3:53 p.m. OK Rust 2024 TESTS 38 406 22220800
388823758 Ravnik E Aug. 29, 2026, 4:04 p.m. OK Rust 2024 TESTS 38 468 64614400

remove filters

Back to search problems