Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll giveres(int pos,int id,int lo,int hi,int flag,ll num){
- if(pos==(int)v.size()){
- if(flag){
- return 1;
- }
- else return 0;
- }
- ll &ret = dp[pos][id][lo][hi][flag];
- if(ret!=-1)return ret;ret = 0;
- int low,high;
- if(lo)low = v[pos];
- else low = 0;
- if(hi)high = v2[pos];
- else high = 9;
- for(int i = low;i<=high;i++){
- int state = id;
- while(state!=-1&&!to[state][i])state = link[state];
- if(state==-1)state = 0;
- state = to[state][i];
- ret+=giveres(pos+1,state,lo&(i==low),hi&(i==high),flag|(int)ending[state].size()>0,num*10+i);
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement