1025. Divisor Game Easy

@problem@discussion
#Math#Dynamic Programming#Brainteaser#Game Theory



1/**
2 * [1025] 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 * 
7 * 	Choosing any x with 0 < x < n and n % x == 0.
8 * 	Replacing the number n on the chalkboard with n - x.
9 * 
10 * Also, if a player cannot make a move, they lose the game.
11 * Return true if and only if Alice wins the game, assuming both players play optimally.
12 *  
13 * Example 1:
14 * 
15 * Input: n = 2
16 * Output: true
17 * Explanation: Alice chooses 1, and Bob has no more moves.
18 * 
19 * Example 2:
20 * 
21 * Input: n = 3
22 * Output: false
23 * Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= n <= 1000
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/divisor-game/
34// discuss: https://leetcode.com/problems/divisor-game/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn divisor_game(n: i32) -> bool {
40        false
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_1025() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.