LOGGERS: Test case related to problem

In the loggers link problem each log can be cut down into smaller logs of size greater than 1, but for some of the size of there may be chance the log can be cut down in different number of times for example log of size 4 can be cut down in 2 ways (3,1)->(1.5,1.5) or (2,2)->(1,1)(1,1) .As in question it is mentioned that both the players will play optimally then according both the possible case must be considered.

I have taken a single test case of
4 2

here as Alice makes the first move Alice should win as she will choose the best way to cut log of size 4 so that she can win. The cutting moves would be

  1. First alice will cut log of size 4 to (3,1)
  2. Now for Bob he has only 2 options cutting log of size 2 or 3 if he choose 2 in the next move Alice will cut the last log and she would win.

But in most of the accepted solution the answer to this test case is Bob.

I cant understand how to consider such case in coding.
Please help me in this matter

I think that you thought that input is 1 2 4 2 (1 testcase, 2 logs and their lengths are 4 and 2), when Bob in second step cuts 3 to 1 + 2, there are logs 1 1 2 2, in next round Alice is cutting and then Bob and he is winner.

1 Like

Yes… Thanks a lot I didtnt read the question properly…