数位DP集合
hdu2089不要62 #include<bits/stdc++.h> using namespace std; #define long long ll int a[20];//存数字 int dp[20][2]; int dfs(int count/*位数*/,int pre/*用于排除62的情况*/,int sta/*状态*/,bool limit/*判断是否有上限*/){ if(count == -1) return 1; if(!limit && dp[count][sta] != -1) return dp[count][sta];//退出递归 int up = limit ? a[count] : 9; int tmp = 0; for(int i = 0;i <= up;i++){ if(pre == 6 && i == 2)/*排除62的情况*/ continue; if(i == 4)/*排除4的情况*/ continue; tmp += dfs(count-1,i,i == 6,limit && i == a[count]); } if(!limit) dp[count][sta] = tmp; return tmp; } int solve(int x){//将数拆开存在数组里 int count = 0; while(x){ a[count++] = x