Created
September 15, 2025 17:38
-
-
Save abiriadev/f47ed6f9e245ec5b82a81442258ed1ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n = 10, s = 10 | |
const x = s * n, m = s ** n | |
const dp = Array(n).fill(0).map(() => Array(x)) | |
const ij = (i, j) => (i === -1 && j === -1 ? 1 : dp[i]?.[j] ?? 0) | |
for (let i = 0; i < n; ++i) | |
for (let j = i; j < x; ++j) | |
dp[i][j] = ij(i, j - 1) + ij(i - 1, j - 1) - ij(i - 1, j - (s + 1)) | |
const p = dp[n - 1].map((c) => (c * c) / (m * m)).reduce((a, b) => a + b, 0) | |
console.log(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment