Codeforces Round 1079 (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
2196 Codeforces Round 1079 (Div. 1) FINISHED False 10800 5585123 Feb. 11, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 15496 ) A Game with a Fraction PROGRAMMING games math

Alice and Bob have two integers (p) and (q), and they are playing a game with these numbers. The players take turns, with Alice going first. On their turn, a player can do one of two actions: decrease (p) by one (this action is possible if (p \gt 0)); decrease (q) by one (this action is possible if (q \gt 1)). The game ends when (p = 0) and (q = 1). Bob wins if at any point during the game the fraction (\frac{p}{q}) is equal to in value the fraction (\frac{2}{3}). Otherwise, Alice wins. Given the initial values of (p) and (q), determine the winner of the game if both players play optimally. 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. Each input case consists of a single line containing two integers (p) and (q) ((1 \le p, q \le 10^{18})). For each input case, output: " Alice " if Alice wins; " Bob " if Bob wins. In the first input case, the fraction is already equal to (\frac{2}{3}) by value, so Bob wins. In the second input case, one possible sequence of the game is as follows: initially (p = 10, q = 14); after Alice's turn (p = 9, q = 14); after Bob's turn (p = 9, q = 13); after Alice's turn (p = 9, q = 12); after Bob's turn (p = 8, q = 12). Bob wins, as (\frac{8}{12}) is equal to (\frac{2}{3}). It can be shown that in this example, with optimal play from both players, Bob always wins. For the third input case, Alice's optimal strategy will be to decrease (q) as long as possible. In this case, the game will end in favor of Alice regardless of Bob's actions.

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
362417472 -firefly- A Feb. 11, 2026, 2:42 p.m. OK C# 13 TESTS 10 62 614400
362568687 s1mply A Feb. 12, 2026, 3:52 a.m. OK C++17 (GCC 7-32) TESTS 10 31 0
362432175 rajk_524 A Feb. 11, 2026, 2:55 p.m. OK C++17 (GCC 7-32) TESTS 10 31 0
362430111 clarinha A Feb. 11, 2026, 2:53 p.m. OK C++17 (GCC 7-32) TESTS 10 31 0
362420222 yangchang A Feb. 11, 2026, 2:44 p.m. OK C++17 (GCC 7-32) TESTS 10 31 0
362568377 hydroiodi926 A Feb. 12, 2026, 3:49 a.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362567240 Pericyclion A Feb. 12, 2026, 3:31 a.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362557867 AJNJ A Feb. 11, 2026, 11:54 p.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362435026 Surge568 A Feb. 11, 2026, 2:58 p.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362428600 magnuseifr A Feb. 11, 2026, 2:51 p.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362425798 over_hero A Feb. 11, 2026, 2:49 p.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
362413815 _istil A Feb. 11, 2026, 2:39 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362432995 BlueMoon. A Feb. 11, 2026, 2:56 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362427400 leg A Feb. 11, 2026, 2:50 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362425740 MvKaio A Feb. 11, 2026, 2:49 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362425598 Xellos A Feb. 11, 2026, 2:48 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362424956 lddlinan A Feb. 11, 2026, 2:48 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362424825 The_Caspian_Sea A Feb. 11, 2026, 2:48 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362419722 noya2 A Feb. 11, 2026, 2:43 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362414727 oyasumi_sion A Feb. 11, 2026, 2:40 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
362572117 Believer_112 A Feb. 12, 2026, 4:36 a.m. OK C++20 (GCC 13-64) TESTS 10 31 102400
362437753 tgossett A Feb. 11, 2026, 3:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362577890 SoloRE A Feb. 12, 2026, 5:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362559357 Pratik_Magdum A Feb. 12, 2026, 12:37 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362554410 p_nag A Feb. 11, 2026, 10:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362546486 3Smileee A Feb. 11, 2026, 8:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362540764 pillowpillow A Feb. 11, 2026, 7:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362535411 weirdflexbutok A Feb. 11, 2026, 6:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362450532 Ladamalina A Feb. 11, 2026, 3:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362442038 showtime A Feb. 11, 2026, 3:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362441715 Tinoz A Feb. 11, 2026, 3:05 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
362419327 hos.lyric A Feb. 11, 2026, 2:43 p.m. OK D TESTS 10 46 0
362427830 Gassa A Feb. 11, 2026, 2:51 p.m. OK D TESTS 10 62 102400
362417620 pengin_2000 A Feb. 11, 2026, 2:42 p.m. OK GNU C11 TESTS 10 15 0
362412068 __baozii__ A Feb. 11, 2026, 2:37 p.m. OK Go TESTS 10 31 1228800
362568287 LittleGopher A Feb. 12, 2026, 3:48 a.m. OK Go TESTS 10 46 614400
362568956 LittleGopher A Feb. 12, 2026, 3:55 a.m. OK Go TESTS 10 62 819200
362424567 iakovlev.zakhar A Feb. 11, 2026, 2:48 p.m. OK Java 21 TESTS 10 203 0
362556576 mastacoda A Feb. 11, 2026, 11:16 p.m. OK Java 21 TESTS 10 203 409600
362440081 Hmzaawy A Feb. 11, 2026, 3:03 p.m. OK Java 21 TESTS 10 218 409600
362444509 MBBN A Feb. 11, 2026, 3:08 p.m. OK Java 21 TESTS 10 218 614400
362414693 sahasrad A Feb. 11, 2026, 2:40 p.m. OK Java 21 TESTS 10 218 921600
362430473 SumitXorY A Feb. 11, 2026, 2:53 p.m. OK Java 21 TESTS 10 265 1843200
362413042 gotexans A Feb. 11, 2026, 2:38 p.m. OK Java 8 TESTS 10 171 0
362424350 Tlatoani A Feb. 11, 2026, 2:47 p.m. OK Kotlin 2.2 TESTS 10 171 102400
362425199 surajchip2 A Feb. 11, 2026, 2:48 p.m. OK PyPy 3 TESTS 10 234 4915200
362428469 Emikooh A Feb. 11, 2026, 2:51 p.m. OK PyPy 3-64 TESTS 10 78 2150400
362418656 stan23456 A Feb. 11, 2026, 2:42 p.m. OK PyPy 3-64 TESTS 10 93 3379200
362558937 SsyHow A Feb. 12, 2026, 12:25 a.m. OK PyPy 3-64 TESTS 10 93 4300800
362414279 Ritwin A Feb. 11, 2026, 2:39 p.m. OK PyPy 3-64 TESTS 10 93 4608000
362413839 McPqndq A Feb. 11, 2026, 2:39 p.m. OK PyPy 3-64 TESTS 10 109 3891200
362422485 smilences A Feb. 11, 2026, 2:46 p.m. OK PyPy 3-64 TESTS 10 109 3993600
362422614 ThatOnePythonUser A Feb. 11, 2026, 2:46 p.m. OK PyPy 3-64 TESTS 10 109 4096000
362416260 osjoon A Feb. 11, 2026, 2:41 p.m. OK PyPy 3-64 TESTS 10 109 4198400
362557227 arjun151 A Feb. 11, 2026, 11:36 p.m. OK PyPy 3-64 TESTS 10 109 4198400
362429189 tassei903 A Feb. 11, 2026, 2:52 p.m. OK PyPy 3-64 TESTS 10 109 4300800
362551475 mr_golem A Feb. 11, 2026, 9:28 p.m. OK Python 3 TESTS 10 78 102400
362559148 bananaeat346 A Feb. 12, 2026, 12:31 a.m. OK Python 3 TESTS 10 93 0
362416050 shade34 A Feb. 11, 2026, 2:41 p.m. OK Python 3 TESTS 10 93 0
362579214 honghua-zhang A Feb. 12, 2026, 5:59 a.m. OK Python 3 TESTS 10 93 102400
362568955 biltharesatyendra A Feb. 12, 2026, 3:55 a.m. OK Python 3 TESTS 10 93 102400
362556555 ahmed.gasmi A Feb. 11, 2026, 11:15 p.m. OK Python 3 TESTS 10 93 102400
362556206 mahmoudelyamen A Feb. 11, 2026, 11:05 p.m. OK Python 3 TESTS 10 93 102400
362423173 YamOCHca A Feb. 11, 2026, 2:46 p.m. OK Python 3 TESTS 10 93 1536000
362544782 neura123 A Feb. 11, 2026, 8:01 p.m. OK Python 3 TESTS 10 109 0
362420243 sansen A Feb. 11, 2026, 2:44 p.m. OK Rust 2021 TESTS 10 46 102400
362422292 darkkcyan A Feb. 11, 2026, 2:46 p.m. OK Rust 2024 TESTS 10 46 0
362416634 Sugar_fan A Feb. 11, 2026, 2:41 p.m. OK Rust 2024 TESTS 10 46 0
362436370 DanielAnker A Feb. 11, 2026, 2:59 p.m. OK Rust 2024 TESTS 10 46 11776000
362423591 Mon_ster A Feb. 11, 2026, 2:47 p.m. OK Rust 2024 TESTS 10 46 11776000
362413319 Egor A Feb. 11, 2026, 2:39 p.m. OK Rust 2024 TESTS 10 46 11776000

remove filters

Back to search problems