Simple DP + Maths Problem!!
Code\n\nclass Solution {\npublic:\n\n    long long ans = 0 , mod = 1e9+7;\n\n    int power(long long a,long long b) {\n        long long res = 1;\n        while
# Code\n```\nclass Solution {\npublic:\n\n    long long ans = 0 , mod = 1e9+7;\n\n    int power(long long a,long long b) {\n        long long res = 1;\n        while(b > 0) {\n            if(b%2) {\n                res = (res*a)%mod;\n                b--;\n            } else {\n                a = (a*a)%mod;\n                b /= 2;\n            }\n        }\n        return res;\n    }\n\n    int solve(int idx,vector<int> &arr,int k,int curr,int len,int n,vector<vector<vector<int>>> &mem) {\n\n        if(idx == n) {\n            if(curr == k) {\n                int rem = n-len;\n                int res = power(2ll,1ll*rem)%mod;\n                return res;\n            }\n            return 0; \n        }\n\n        if(mem[idx][curr][len] != -1) return mem[idx][curr][len];\n\n\n        int res = 0;\n\n        // take\n        if(curr + arr[idx] <= k) {\n            res = (res + solve(idx+1,arr,k,curr+arr[idx],len+1,n,mem))%mod;\n        }\n\n        // don\'t\n        res = (res + solve(idx+1,arr,k,curr,len,n,mem))%mod;\n\n        return mem[idx][curr][len] = res;\n    }\n\n    int sumOfPower(vector<int>& nums, int k) {\n        int n = nums.size();\n\n        vector<vector<vector<int>>> mem(n+1,vector<vector<int>>(k+1,vector<int>(n+1,-1)));\n    \n        return solve(0,nums,k,0,0,n,mem);\n    }\n};\n```
['Math', 'Dynamic Programming', 'C++']