//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "数位DP  (Windy数)": {
        "prefix": "acm-5.3dfs",
        "body": [
            "#include<cstring>",
            "#include<cstdio>",
            "#include<cmath>",
            "#define R register int",
            "using namespace std;",
            "int a,b,l,num[12],dp[12][10];",
            "inline int dfs(int len,int up,int ok){",
            "    R i,ed,ans=0;",
            "    if(len<1)return 1;",
            "    if(!ok&&~dp[len][up]&&up!=-7)return dp[len][up];",
            "    ed=ok?num[len]:9;",
            "    for(i=0;i<=ed;i++)if(abs(i-up)>=2)",
            "        ans+=dfs(len-1,(!i&&up==-7)?up:i,ok&&(i==ed));",
            "    if(!ok&&up!=-7)dp[len][up]=ans;",
            "    return ans;",
            "}",
            "inline int sovle(int x){",
            "    l=0;",
            "    while(x)num[++l]=x%10,x/=10;",
            "    return dfs(l,-7,1);",
            "}",
            "int main(){",
            "    scanf(\"%d%d\",&a,&b);",
            "    memset(dp,-1,sizeof(dp));",
            "    printf(\"%d\",sovle(b)-sovle(a-1));",
            "}",
            ""
        ],
        "description": "插入 数位DP  (Windy数)"
    }
}