Codeforces Round 669 (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
1407 Codeforces Round 669 (Div. 2) FINISHED False 7200 137604263 Sept. 8, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 17195 ) B Big Vova PROGRAMMING brute force greedy math number theory

B'Alexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recently opened a store on the popular online marketplace "Zmey-Gorynych", and offers Alex a job: if he shows his programming skills by solving a task, he 'll work as a cybersecurity specialist. Otherwise, he 'll be delivering some doubtful products for the next two years. You 're given n positive integers a_1, a_2, ... , a_n . Using each of them exactly at once, you 're to make such sequence b_1, b_2, ... , b_n that sequence c_1, c_2, ... , c_n is lexicographically maximal, where c_i=GCD(b_1, ... ,b_i) - the greatest common divisor of the first i elements of b . Alexander is really afraid of the conditions of this simple task, so he asks you to solve it. A sequence a is lexicographically smaller than a sequence b if and only if one of the following holds: Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^3 ). Description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 10^3 ) -- the length of the sequence a . The second line of each test case contains n integers a_1, ... ,a_n ( 1 <= a_i <= 10^3 ) -- the sequence a . It is guaranteed that the sum of n over all test cases does not exceed 10^3 . For each test case output the answer in a single line -- the desired sequence b . If there are multiple answers, print any. In the first test case of the example, there are only two possible permutations b -- [2, 5] and [5, 2] : for the first one c=[2, 1] , for the second one c=[5, 1] . In the third test case of the example, number 9 should be the first in b , and GCD(9, 3)=3 , GCD(9, 8)='...

Tutorials

Codeforces Round #669 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
92299485 flayer_hunter B Sept. 8, 2020, 7:35 p.m. OK GNU C11 TESTS 15 31 0
92289192 abcd227 B Sept. 8, 2020, 5:24 p.m. OK GNU C11 TESTS 15 46 0
92319987 computerkiller B Sept. 9, 2020, 5:18 a.m. OK GNU C++11 TESTS 15 15 0
92313677 ArvinCiu B Sept. 9, 2020, 3:12 a.m. OK GNU C++11 TESTS 15 15 0
92311059 SONGYJ9 B Sept. 9, 2020, 1:59 a.m. OK GNU C++11 TESTS 15 15 0
92303877 tayyibaalazad B Sept. 8, 2020, 9:12 p.m. OK GNU C++11 TESTS 15 15 0
92293187 NadmanKhan B Sept. 8, 2020, 6:04 p.m. OK GNU C++11 TESTS 15 15 0
92288696 albano04 B Sept. 8, 2020, 5:20 p.m. OK GNU C++11 TESTS 15 15 0
92288490 sidne B Sept. 8, 2020, 5:18 p.m. OK GNU C++11 TESTS 15 15 0
92287133 nietzschewalrus779 B Sept. 8, 2020, 5:09 p.m. OK GNU C++11 TESTS 15 15 0
92318983 Rae1 B Sept. 9, 2020, 5:02 a.m. OK GNU C++11 TESTS 15 15 0
92313966 ASTROBOYZZ B Sept. 9, 2020, 3:19 a.m. OK GNU C++11 TESTS 15 15 0
92285700 omhari B Sept. 8, 2020, 5:03 p.m. OK GNU C++14 TESTS 15 15 0
92280145 IITauqeer B Sept. 8, 2020, 4:27 p.m. OK GNU C++14 TESTS 15 15 0
92316501 sinthia.rupa71 B Sept. 9, 2020, 4:13 a.m. OK GNU C++14 TESTS 15 15 0
92301377 attitude03 B Sept. 8, 2020, 8:09 p.m. OK GNU C++14 TESTS 15 15 0
92279765 DemonSlayerpyf B Sept. 8, 2020, 4:26 p.m. OK GNU C++14 TESTS 15 15 102400
92313444 MPRUDRA B Sept. 9, 2020, 3:07 a.m. OK GNU C++14 TESTS 15 30 0
92310556 MelodySz B Sept. 9, 2020, 1:40 a.m. OK GNU C++14 TESTS 15 30 0
92308852 might1331 B Sept. 9, 2020, 12:31 a.m. OK GNU C++14 TESTS 15 30 0
92314592 deo002 B Sept. 9, 2020, 3:33 a.m. OK GNU C++14 TESTS 15 30 0
92322062 AtiBansal B Sept. 9, 2020, 5:50 a.m. OK GNU C++14 TESTS 15 30 0
92319183 vispecia B Sept. 9, 2020, 5:06 a.m. OK GNU C++17 TESTS 15 15 0
92282727 siddhant19_ B Sept. 8, 2020, 4:32 p.m. OK GNU C++17 TESTS 15 15 102400
92313749 IvnF B Sept. 9, 2020, 3:14 a.m. OK GNU C++17 TESTS 15 15 102400
92279751 yash_27 B Sept. 8, 2020, 4:26 p.m. OK GNU C++17 TESTS 15 15 204800
92280716 incognito__ B Sept. 8, 2020, 4:28 p.m. OK GNU C++17 TESTS 15 15 307200
92281384 ritvikush B Sept. 8, 2020, 4:29 p.m. OK GNU C++17 TESTS 15 15 409600
92304894 alpvj B Sept. 8, 2020, 9:44 p.m. OK GNU C++17 TESTS 15 15 409600
92296144 DSR_TFB B Sept. 8, 2020, 6:43 p.m. OK GNU C++17 TESTS 15 30 0
92322256 smayankpratap B Sept. 9, 2020, 5:53 a.m. OK GNU C++17 TESTS 15 30 0
92307316 Zhang_sir00 B Sept. 8, 2020, 11:22 p.m. OK GNU C++17 TESTS 15 30 0
92320634 __utkarshvashisth94__ B Sept. 9, 2020, 5:28 a.m. OK GNU C++17 (64) TESTS 15 15 0
92291732 roastedcoder B Sept. 8, 2020, 5:49 p.m. OK GNU C++17 (64) TESTS 15 15 0
92290714 kenechi B Sept. 8, 2020, 5:38 p.m. OK GNU C++17 (64) TESTS 15 15 0
92289390 kritin19 B Sept. 8, 2020, 5:26 p.m. OK GNU C++17 (64) TESTS 15 15 0
92279764 Mohamed_Sayed B Sept. 8, 2020, 4:26 p.m. OK GNU C++17 (64) TESTS 15 15 0
92322587 CODESofRishi B Sept. 9, 2020, 5:59 a.m. OK GNU C++17 (64) TESTS 15 15 0
92321254 12662 B Sept. 9, 2020, 5:38 a.m. OK GNU C++17 (64) TESTS 15 15 0
92285831 Zahidul_Islam B Sept. 8, 2020, 5:03 p.m. OK GNU C++17 (64) TESTS 15 15 204800
92285522 blackomega B Sept. 8, 2020, 5:02 p.m. OK GNU C++17 (64) TESTS 15 15 307200
92291922 David_Garcia B Sept. 8, 2020, 5:50 p.m. OK GNU C++17 (64) TESTS 15 15 409600
92290336 jegfault B Sept. 8, 2020, 5:34 p.m. OK Haskell TESTS 15 31 102400
92303332 skittles1412 B Sept. 8, 2020, 8:56 p.m. OK Java 11 TESTS 15 171 0
92296743 big_boy_coder B Sept. 8, 2020, 6:52 p.m. OK Java 11 TESTS 15 186 0
92285495 Dominatus B Sept. 8, 2020, 5:02 p.m. OK Java 11 TESTS 15 186 0
92312740 insert_cool_handle B Sept. 9, 2020, 2:48 a.m. OK Java 11 TESTS 15 187 0
92301029 _prophet B Sept. 8, 2020, 8:02 p.m. OK Java 11 TESTS 15 187 0
92303908 jayesh_patil B Sept. 8, 2020, 9:13 p.m. OK Java 11 TESTS 15 202 0
92314387 thapliyaladiti215 B Sept. 9, 2020, 3:28 a.m. OK Java 11 TESTS 15 202 0
92306623 _apurv_ B Sept. 8, 2020, 10:47 p.m. OK Java 11 TESTS 15 202 0
92296977 mrawk B Sept. 8, 2020, 6:55 p.m. OK Java 11 TESTS 15 202 0
92288221 nirvana_rsc B Sept. 8, 2020, 5:16 p.m. OK Java 11 TESTS 15 202 0
92317671 shashwat07 B Sept. 9, 2020, 4:36 a.m. OK Java 8 TESTS 15 93 0
92312266 jon_snow_1999 B Sept. 9, 2020, 2:36 a.m. OK Java 8 TESTS 15 108 0
92292040 devkbabarwal B Sept. 8, 2020, 5:52 p.m. OK Java 8 TESTS 15 108 0
92316797 ashraybharambe B Sept. 9, 2020, 4:19 a.m. OK Java 8 TESTS 15 109 0
92312277 sankcan55 B Sept. 9, 2020, 2:36 a.m. OK Java 8 TESTS 15 109 0
92310586 AayushICS B Sept. 9, 2020, 1:41 a.m. OK Java 8 TESTS 15 109 0
92296810 noobie_code B Sept. 8, 2020, 6:53 p.m. OK Java 8 TESTS 15 109 0
92296770 rdsaurabh97 B Sept. 8, 2020, 6:52 p.m. OK Java 8 TESTS 15 109 0
92294665 kalzor B Sept. 8, 2020, 6:22 p.m. OK Java 8 TESTS 15 109 0
92289405 robinz62 B Sept. 8, 2020, 5:26 p.m. OK Java 8 TESTS 15 109 0
92291247 koper B Sept. 8, 2020, 5:43 p.m. OK Kotlin TESTS 15 155 1740800
92307660 speshuric B Sept. 8, 2020, 11:39 p.m. OK Kotlin TESTS 15 170 819200
92320836 greysheep B Sept. 9, 2020, 5:31 a.m. OK MS C++ 2017 TESTS 15 31 0
92294822 ustaritz B Sept. 8, 2020, 6:24 p.m. OK MS C++ 2017 TESTS 15 31 0
92287105 paulmorenkov B Sept. 8, 2020, 5:09 p.m. OK MS C++ 2017 TESTS 15 31 0
92317426 pandoomanda B Sept. 9, 2020, 4:32 a.m. OK MS C++ 2017 TESTS 15 46 0
92288633 raj1307 B Sept. 8, 2020, 5:20 p.m. OK PyPy 2 TESTS 15 109 1433600
92288591 raj1307 B Sept. 8, 2020, 5:19 p.m. OK PyPy 2 TESTS 15 109 1536000
92296999 raj1307 B Sept. 8, 2020, 6:56 p.m. OK PyPy 2 TESTS 15 124 921600
92293939 raj1307 B Sept. 8, 2020, 6:13 p.m. OK PyPy 2 TESTS 15 124 921600
92298831 raj1307 B Sept. 8, 2020, 7:23 p.m. OK PyPy 2 TESTS 15 124 1024000
92296893 raj1307 B Sept. 8, 2020, 6:54 p.m. OK PyPy 2 TESTS 15 124 1024000
92297270 raj1307 B Sept. 8, 2020, 7 p.m. OK PyPy 2 TESTS 15 124 1433600
92289426 raj1307 B Sept. 8, 2020, 5:26 p.m. OK PyPy 2 TESTS 15 124 1433600
92287678 raj1307 B Sept. 8, 2020, 5:12 p.m. OK PyPy 2 TESTS 15 124 1433600
92288379 raj1307 B Sept. 8, 2020, 5:17 p.m. OK PyPy 2 TESTS 15 124 1536000
92285563 Lotus007 B Sept. 8, 2020, 5:02 p.m. OK PyPy 3 TESTS 15 140 1638400
92314229 mahmudula2000 B Sept. 9, 2020, 3:24 a.m. OK PyPy 3 TESTS 15 155 1536000
92290815 pajenegod B Sept. 8, 2020, 5:39 p.m. OK PyPy 3 TESTS 15 155 1843200
92290759 pajenegod B Sept. 8, 2020, 5:38 p.m. OK PyPy 3 TESTS 15 155 1945600
92286286 Akhil_Rautela B Sept. 8, 2020, 5:05 p.m. OK PyPy 3 TESTS 15 155 1945600
92315558 codershuvo B Sept. 9, 2020, 3:54 a.m. OK PyPy 3 TESTS 15 155 2048000
92285994 ng24_7 B Sept. 8, 2020, 5:04 p.m. OK PyPy 3 TESTS 15 155 2048000
92299397 dutt_shouvik B Sept. 8, 2020, 7:33 p.m. OK PyPy 3 TESTS 15 155 2355200
92292888 Ajay_Modi B Sept. 8, 2020, 6:01 p.m. OK PyPy 3 TESTS 15 155 2560000
92321732 chill_house B Sept. 9, 2020, 5:45 a.m. OK PyPy 3 TESTS 15 155 2662400
92294021 pajenegod B Sept. 8, 2020, 6:14 p.m. OK Python 2 TESTS 15 311 102400
92283190 kmd99 B Sept. 8, 2020, 4:33 p.m. OK Python 2 TESTS 15 389 0
92282554 devamk B Sept. 8, 2020, 4:32 p.m. OK Python 3 TESTS 15 108 307200
92315407 thnkndblv B Sept. 9, 2020, 3:51 a.m. OK Python 3 TESTS 15 109 307200
92299454 dutt_shouvik B Sept. 8, 2020, 7:34 p.m. OK Python 3 TESTS 15 109 307200
92287633 Gausstein B Sept. 8, 2020, 5:12 p.m. OK Python 3 TESTS 15 109 307200
92283580 dev_k7 B Sept. 8, 2020, 4:33 p.m. OK Python 3 TESTS 15 124 307200
92281435 greature24 B Sept. 8, 2020, 4:29 p.m. OK Python 3 TESTS 15 124 307200
92310115 eugalt B Sept. 9, 2020, 1:24 a.m. OK Python 3 TESTS 15 139 307200
92310465 eugalt B Sept. 9, 2020, 1:37 a.m. OK Python 3 TESTS 15 140 307200
92310341 eugalt B Sept. 9, 2020, 1:32 a.m. OK Python 3 TESTS 15 140 307200
92311641 KanhuKeNanu B Sept. 9, 2020, 2:18 a.m. OK Python 3 TESTS 15 171 307200

remove filters

Back to search problems