hdu4734

int dp[20][10005];
int digit[20];
int getvalue(int a)
{
    int i=0;
    int ans=0;
    while(a){
        ans=ans+((a%10)*(1<=0;
    int ans=0;
    int up=limit?digit[pos]:9;
    for(int i=0;i<=up;i++){
        ans+=dfs(pos-1,state-i*(1<<(pos-1)),limit&&i==digit[pos]);
    }
    if(!limit)dp[pos][state]=ans;
    return ans;
}

int solve(int b,int a)
{
    int pos=0;
    while(b){
        digit[pos++]=b%10;
         b/=10;
    }
    return dfs(pos,getvalue(a),1);
}

int main()
{
    int t;
    cin>>t;
    while(t--){
        memset(dp,-1,sizeof(dp));
        cin>>a>>b;
        cout<

你可能感兴趣的:(数位dp)