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

mom0kawa50's blog

By mom0kawa50, history, 4 hours ago, In English

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)

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it