Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def findWinner(self,n,x,y):
- dp=[[None]*(3) for i in range(1+n)]
- def help(coins,pos):
- if coins<0:return False
- if coins==0:
- if pos==1:return True
- else:return False
- if dp[coins][pos]!=None:return dp[coins][pos]
- if pos==0:
- dp[coins][pos]=help(coins-x,1) or help(coins-y,1) or help(coins-1,1)
- else:
- dp[coins][pos]= help(coins-x,0) or help(coins-y,0) or help(coins-1,0)
- return dp[coins][pos]
- return 1 if help(n,0) else 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement