3D DP implemented in an unconventional manner
\n# Code\n\n#define ll long long\nclass Solution {\npublic:\n\n    ll binpow(ll a, ll b) {\n    ll m= 1e9 + 7;\n    a %= m;\n    long long res = 1;\n    while (
\n# Code\n```\n#define ll long long\nclass Solution {\npublic:\n\n    ll binpow(ll a, ll b) {\n    ll m= 1e9 + 7;\n    a %= m;\n    long long res = 1;\n    while (b > 0) {\n        if (b & 1)\n            res = res * a % m;\n        a = a * a % m;\n        b >>= 1;\n    }\n    return res;\n}\n    int sumOfPower(vector<int>& nums, int k) {\n        ll mod =1e9 +7;\n        ll res=0;\n        vector<int>v;\n        vector<vector<int>>prev{{0, 0}};\n\n        map<vector<int>, ll>mprev;\n        mprev[{0, 0}]=1;\n        for(int i=0;i<nums.size();i++){\n            vector<vector<int>>cur;\n            map<vector<int>, ll>mcur;\n            for(auto j:prev){\n                vector<int>t=j;\n                // t.push_back(nums[i]);\n                t[0]+=nums[i];\n                t[1]++;\n\n\n                if(t[0]<=k){\n                    if(!mcur[t]){\n                        cur.push_back(t);\n                    }\n                    mcur[t]=(mcur[t]+mprev[j])%mod;\n                }\n                if(t[0]==k){\n                    ll t1=mprev[j];\n                    ll t2=t[1];\n                    \n                    res= (res+((t1%mod)*(binpow(2, (nums.size()-t2))%mod))%mod)%mod;\n                    res%=mod;\n                }\n                \n                if(!mcur[j]){\n                    cur.push_back(j);\n                }\n                mcur[j]=(mcur[j]+mprev[j]);   \n\n            }\n\n            prev=cur;\n            mprev=mcur;\n           \n        }\n        \n        return res;\n    }\n};\n```
['C++']