Think:
1知识点:数位DP
2题意:输入r,判断[1, r]区间内有多少个“wqb-number”,“wqb-number”的定义为数位内含有13且可以被13整除,例如13,2613是“wqb-number”,而143和131不是“wqb-number”,143中1和3不是连续存在,131不能被13整除。
3反思:
(1):dp数组的控制条件应与dfs中控制变量相对应
(2):dp[pos][is_13][num][pre];
(3):dfs(pos, is_13, num, pre, is_max);
以下为Wrong Answer代码——dp数组的控制条件无is_13
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int dp[24][24][14], tp, link[24];
int dfs(int pos, bool is_13, int num, int pre, bool is_max);
int solve(int x);
int main(){
memset(dp, -1, sizeof(dp));
int r;
while(~scanf("%d", &r)){