File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Problem Link: https://leetcode.com/problems/divisor-game/
3
+
4
+ Alice and Bob take turns playing a game, with Alice starting first.
5
+ Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of:
6
+ Choosing any x with 0 < x < N and N % x == 0.
7
+ Replacing the number N on the chalkboard with N - x.
8
+ Also, if a player cannot make a move, they lose the game.
9
+ Return True if and only if Alice wins the game, assuming both players play optimally.
10
+
11
+ Example 1:
12
+ Input: 2
13
+ Output: true
14
+ Explanation: Alice chooses 1, and Bob has no more moves.
15
+
16
+ Example 2:
17
+ Input: 3
18
+ Output: false
19
+ Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
20
+
21
+ Note:
22
+ 1 <= N <= 1000
23
+ """
24
+ class Solution :
25
+ def divisorGame (self , N : int ) -> bool :
26
+ return N % 2 == 0
You can’t perform that action at this time.
0 commit comments