C++ Accumulate Probabilities
cpp\nvector<pair<int, int>> jumps = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\ndouble knightProbability(int N, int K, int r, int
```cpp\nvector<pair<int, int>> jumps = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\ndouble knightProbability(int N, int K, int r, int c) {\n    vector<vector<double>> b(N, vector<double>(N, 1));\n    while (--K >= 0) {\n        vector<vector<double>> b1(N, vector<double>(N));\n        for (auto i = 0; i < N; ++i)\n            for (auto j = 0; j < N; ++j) {\n                if (b[i][j] == 0)\n                    continue;\n                auto p = b[i][j] / 8;\n                for (auto [di, dj] : jumps)\n                    if (i + di >= 0 && j + dj >= 0 && i + di < N && j + dj < N)\n                        b1[i + di][j + dj] += p;\n            }\n        swap(b, b1);\n    }\n    return b[r][c];\n}\n```\n**Complexity Analysis**\n- Time: O(n * n * k)\n- Memory: O(n * n)
[]