Python3 Solution
\n\nclass Solution:\n    def knightProbability(self, n: int, k: int, row: int, column: int) -> float:\n        @lru_cache(None)\n        def dp(cur_r,cur_c,k):\
\n```\nclass Solution:\n    def knightProbability(self, n: int, k: int, row: int, column: int) -> float:\n        @lru_cache(None)\n        def dp(cur_r,cur_c,k):\n            if k==0:\n                return 1\n\n            else:\n                ans=0\n                for r,c in moves:\n                    now_r=cur_r+r\n                    now_c=cur_c+c\n                    if 0<=now_r<=n-1 and 0<=now_c<=n-1:\n                        ans+=dp(now_r,now_c,k-1)\n\n                return ans\n\n        if k==0:\n            return 1\n\n        moves=[[1,2],[2,1],[1,-2],[2,-1],[-1,2],[-2,1],[-1,-2],[-2,-1]]\n        return dp(row,column,k)/8**k            \n\n```
['Python', 'Python3']