[Python 3]DP
DP with memorization with three states\n Pointer for current number\n Remaining target\n* How many numbers used\n \nKey is to compress the state into count hash
DP with memorization with three states\n* Pointer for current number\n* Remaining target\n* How many numbers used\n \nKey is to compress the state into count hashmaps\n\n```\nclass Solution:\n    def sumOfPower(self, nums: List[int], k: int) -> int:\n        \n        cnt = Counter(nums)\n        cands = sorted(cnt)\n        n = len(cands)\n        M = 10 ** 9 + 7\n\n        @cache\n        def dp(i, k, c):\n            \n            if k == 0:\n                return pow(2, len(nums) - c, M)\n            \n            if i == n or cands[i] > k:\n                return 0\n            \n            ans = 0\n            for j in range(min(cnt[cands[i]], k // cands[i])+1):\n                ans = (ans + math.comb(cnt[cands[i]], j)*dp(i+1, k - cands[i]*j, c+j)) % M\n            return ans\n            \n        return dp(0, k, 0)\n\t```
['Dynamic Programming', 'Python', 'Python3']