uestc250windy数数位dp

2020-12-13 06:07

阅读:526

标签:style   blog   color   os   io   for   div   amp   

#include 
#include 
#include 
#include 
#include 
#include string>
#include 
#include 
#include 
#include 
#include set>
#include 
#include using namespace std;

int dp[100][100][2];
int up[1000];
int ab(int x)
{
    return x>0? x:-x;
}

int dfs(int pos,int top,int first,int flag)
{
    if(pos0) return first==1;
    if(first&&!flag&&~dp[pos][top][first]) return dp[pos][top][first];
    int limit = flag? up[pos]: 9,ret=0;
    for(int i= 0;i){ 
        int t= ab(top-i);  
        if(t>=2||!first) ret+=dfs(pos-1,i,first||i,flag&&(i==limit)); //这个判断是海哥告诉的,非常吊,自己品味。
    }
    return  flag? ret: dp[pos][top][first] = ret;
}
int solve(int x)
{
    int len=0;
    while(x){
        up[++len]=x%10;
        x/=10;
    }
    return dfs(len,100,0,1);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        cout1) endl;
    }
    return 0;
}

 

uestc250windy数数位dp,搜素材,soscw.com

uestc250windy数数位dp

标签:style   blog   color   os   io   for   div   amp   

原文地址:http://www.cnblogs.com/yigexigua/p/3896641.html


评论


亲,登录后才可以留言!