Good evening.

I'm glad to welcome you on this Codeforces beta round.

Authors of today problemset are Ripatti (it is me) and Lepetrandr. it4.kp, MikeMirzayanov, RAD, Nerevar and dlevshunov helped in preparing the round. Delinur translated statements into English.

Good luck for all!

UPD

Winner is Neverauskas.

Editorial.

I'm glad to welcome you on this Codeforces beta round.

Authors of today problemset are Ripatti (it is me) and Lepetrandr. it4.kp, MikeMirzayanov, RAD, Nerevar and dlevshunov helped in preparing the round. Delinur translated statements into English.

Good luck for all!

UPD

Winner is Neverauskas.

Editorial.

May be you are right, I think that problems are quiet harder that usual.

But I'm on 19th place, on the first page! *YAHOO*

It gives the correct result, but it's not obvious, and, I suppose, not true.

One of possible winning strategies here is symmetric strategy. If n is even, Marcel has symmetric strategy, so he wins. Otherwise, if Timur can make a turn (m / mindivisor >= k), then he splits one log, so that it parts can't be splited again, and so he gets symmetric strategy for remaining logs.

Nis even. Pair up the logs. Then the opponent can always copy your move for another pair, so you always lose. What ifNis odd? You can deduce from the even case that it is equivalent to play on a single log with lengthM.L, you always try to split it into logs with lengthL' ≥Ksuch that is even. By the above argument opponent always loses. If none of the allowed divisions leads your opponent into even case, try to recur on each possible splitting and see if you can win. It runs pretty fast.N=K= 1.Otherwise, we have two cases:

- N is even, Marsel will win by imitating Timur's actions since at that time, logs are paired up.

- N is odd, Timur simply destroys a log of length M and puts Marsel into the an even position, at which who moves second will win (it is Timur then!). You can see there is always a way to divide the log so that you can not make any move on the newly formed logs (repeatedly divide M by its divisors while this does not make M less than K).

And I love the fast system test :x

aaa

aa

#include <iostream>

#include <stdio.h>

#include <string.h>

using namespace std;

int main () {

freopen("input","r",stdin);

char a[2][4];

for(int j=0;j<2;++j)

fgets(a[j], 4, stdin);

//a[0] is "aaa\0"

//a[1] is "\n\0[trash]"

//so strlen(a[1]=1)

//and your loop is uncorrect

//tested with g++

return 0;

}

"Any scientist in a minute can move down the corridor to the next lab" .