Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

The Solution for CF Round 1137(div.2) A problem

Revision en3, by mom0kawa50, 2026-11-23 04:24:36

A

original problem : 2289A - Problem from Dolgoderevenskoye

For this problem, we quickly think of sorting the conditions by counting the numbers of even nums and odd nums, for an example,

// n means the number on the card Artem chooses which firstly
// evenNum means even numbers on the cards in the cards set and vice versa
if(n%2==0 && evenNum>oddNum){
    return true;
}

this is the first solution which is easier to be found, however, if we write a few examples on the paper, we will find a much more tiny and short formula:

let x = (2^a) * m, (m is an odd number)

then,

oddNum = d(m),

evenNum = a * d(m),

if Artem chooses an even number firstly, then the sequence is like:

E->O->E->O->...

the total number of steps = 2 * min(evenNum,oddNum) + (evenNum>oddNum ? 1 : 0)

to the opposite(Artem chooses the an odd number firstly), it is the same

so the formula of all the n-cases that can make Artem win is

n % 4 != 2

(in my personal preference i like the second solution cuz you just need to write down a few examples and find out the rule)

Tags solutions, codeforces

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English mom0kawa50 2026-11-23 04:24:36 2 Tiny change: 'rmula:\n\n\nlet x ' -> 'rmula:\n\nlet x '
en2 English mom0kawa50 2026-11-23 04:17:19 10
en1 English mom0kawa50 2026-11-23 04:16:12 1139 two solutions of problem A in CF round 1137 div.2 (published)