Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 531 Bytes

1025. 除数博弈.md

File metadata and controls

30 lines (22 loc) · 531 Bytes
  • 动态规划
function divisorGame(n: number): boolean {

    const dp: boolean[] = new Array(n + 1).fill(false);

    for (let N = 1; N <= n; ++N) {
        for (let x = N - 1; x > 0; --x) {
            if (!dp[N - x] && N % x === 0) {
                dp[N] = true;
                break;
            }
        }
    }

    return dp[n];
};
  • 数学
function divisorGame(n: number): boolean {
    return !(n & 1);
};