MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / yo

Function yo

Dynamic Programming Optimizations/Digit DP.cpp:15–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13int pw[20][20], b[1 << 10][3000], cnt[1 << 10], dp[2][20][1 << 10][2520];
14vector<int> v;
15int yo(int i, int mask, int rem, int f) {
16 if(i == -1) return pw[b[mask][rem]][cnt[mask]];
17 int &ret = dp[f][i][mask][rem];
18 if(ret != -1 && !f) return ret;
19 int m = f ? v[i] : 9;
20 int ans = 0;
21 for(int k = 0; k <= m; k++) {
22 ans += yo(i - 1, mask | (1 << k), (rem * 10 + k) % 2520, k == m ? f : 0);
23 if(ans >= mod) ans -= mod;
24 }
25 if(!f) ret = ans;
26 return ans;
27}
28int solve(ll n) {
29 if(n == 0) return 0;
30 v.clear();

Callers 1

solveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected