Friday, August 21, 2015

MJ [21] Who wins IV

Question:
Two players take numbers from a set of numbers nums in turn. A player can only take one number from nums each time. Once a number is taken, it is removed from nums. The sum of all the removed number is denoted by sum. A player wins if sum>target after the player took one number.

Given nums and target, determine whether the first player can win assuming all the numbers is nums and target are positive.

Eg1., if nums = {2,3} and target = 4, the first player loses no matter which number it takes first.

Eg2., if nums = {1,2,3} and target = 4, the first player can win by remove 1 at the 1st step. Then the second can only take 2 or 3. In either case the first player wins by taking the last number left.
Ref
[1] http://www.mitbbs.com/article_t/JobHunting/33010083.html

No comments:

Post a Comment