Created
June 11, 2015 00:29
-
-
Save balamark/8c47353d1841d1167ef9 to your computer and use it in GitHub Desktop.
ref
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int solve(int p, int take, int num){ | |
int &ret = dp[p][take][num]; | |
if(p==n){ | |
if(take>0 and num==0) return ret = 1; | |
return ret = 0; | |
} | |
if(ret!=-1) return ret; | |
int t = (num*10)+(s[p]-'0'); | |
//take digit at position p or not | |
int a = solve(p+1, take+1, t%8); | |
int b = solve(p+1, take, num); | |
return ret = max(a,b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment