![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划:数位DP
文章平均质量分 52
BRCOCOLI
初学者 记录成长 Fighting
展开
-
HDU 4734 F(x) 数位DP .
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4734 状态定义为d[pos][weight] 一开始我DFS时候从前往后加权值 但这无法记忆化 所以可以从前往后减去权值 d[pos][weight] 代表在pos这一位开始枚举,小于等于weight的数有几个 #include #include #include #incl原创 2016-10-09 08:45:08 · 200 阅读 · 0 评论 -
HDU 4507 吉哥系列故事——恨7不成妻 数位DP *
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4507 第一次遇到求平方和的题目. 题解看了半天才懂.. 1、整数中某一位是7; 2、整数的每一位加起来的和是7的整数倍; 3、这个整数是7的整数倍; 对于1,只要我们放的时候略过7就好了 对于2,我们要保存每一位加起来mod 7 的值,我记为modOne 对于3,我原创 2016-10-08 19:18:20 · 314 阅读 · 0 评论 -
HDU 3709 Balanced Number 数位DP -
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3709 枚举支点位置就好了 #include #include #include #include using namespace std; const int maxp=21; typedef long long LL; LL d[maxp][maxp][1601]; int digit[原创 2016-10-08 09:26:12 · 234 阅读 · 0 评论 -
POJ 3252 Round Numbers 数位DP .
题目地址:http://poj.org/problem?id=3252 这次要包含lead表示是否有前导0,因为 00001 和 10000 是不一样的,而他们在状态表示的时候却一样,这样子就状态重叠了 #include #include #include #include using namespace std; const int maxp=33; typedef long lon原创 2016-10-07 17:24:58 · 261 阅读 · 0 评论 -
codeforces 55d A.Beautiful numbers 数位DP -
题目地址:http://vjudge.net/contest/124282#problem/A #include #include #include #include #include using namespace std; typedef long long LL; const int mod=2520; LL d[25][mod][50]; map idxLcm; int dig原创 2016-10-06 22:16:40 · 284 阅读 · 0 评论 -
URAL 1057 Amount of Degrees 数位DP *
题目地址:http://acm.timus.ru/problem.aspx?space=1&num=1057 思路来源:浅谈数位类统计问题 现在才发现数位问题可以转化为一棵二叉搜索树的问题去理解 #include #include #include #include using namespace std; typedef long long LL; LL d[32][32]; LL原创 2016-10-06 21:05:51 · 273 阅读 · 0 评论 -
HDU 3652 B-number 数位DP -
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3652 #include #include #include #include using namespace std; typedef long long LL; LL d[13][3][13]; int digit[13]; int DFS(int pos,int state,int mo原创 2016-10-05 23:59:44 · 224 阅读 · 0 评论 -
HDU 3555 Bomb 数位DP .
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3555 先算出1~n 含有49的有几个,再减一减就好了 #include #include #include #include using namespace std; typedef long long LL; LL d[25][10],digit[20]; void init() {原创 2016-10-05 23:01:18 · 253 阅读 · 0 评论 -
HDU 2089 不要62 数位DP .
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2089 模板题 ,第一道数位DP的题目 #include #include #include #include using namespace std; int d[10][2],a[10]; int DFS(int pos,int pre,int state,bool limit) {原创 2016-10-05 19:51:54 · 329 阅读 · 0 评论 -
数位DP
数位dp是一种计数用的dp,一般就是要统计一个区间[le,ri]内满足一些条件数的个数。比如,[1,10000] 中统计不含有4的数 。 所谓数位dp,字面意思就是在数位上进行dp咯。 就是对数字每一位每一位递推 此类题目最基本的暴力方法: for(int i=le;i if(Check(i)) ans++; 而数位DP就是从最低位起原创 2016-10-05 22:19:31 · 778 阅读 · 0 评论 -
HYSBZ 1799 self 同类分布 数位DP -
题目地址:http://vjudge.net/problem/19309 很明显是数位DP的题目,因为时间很大,所以可以暴力 但是怎么判断能否被整除,这比较麻烦,因为枚举的时候,总数字num在变,每个数和mod也在变 但是由于时间宽裕,而且就一组数据,那么直接枚举mod就好了,mod 1~9+9+9+9+9+9+9... #include #include #include #inc原创 2016-10-09 20:05:49 · 282 阅读 · 0 评论 -
LA 2038 Strategic game 树形DP .
题目地址:http://vjudge.net/problem/UVALive-2038 以前做过类似的题 就是,无根转有根 然后普通的DP d[u][i] 表示u节点的父亲有没有被选中,i==1表示被选中,反之没有 为什么弄u的父节点呢,因为 如果弄u的节点信息,那么当u没被选中,子结点至少有一个要被选中,那么只能枚举被选中的那个,无法递推,有后效性#include <bits/stdc+原创 2016-11-19 19:31:17 · 250 阅读 · 0 评论