数位dp
密歇根卷王
美本转学生
展开
-
poj3252 Round Numbers
题目链接这个题有以下几点要求:1.将给定数字转换为二进制2.对转化后的二进制数字每一位0或1进行统计3.比较0或1数量的大小4.确定是否满足题干上述思想是对一个数进行的计算,然而这个题要求我们求一段区间内满足题意的数,那么我们就要借助数位dp进行操作//这是我的代码#include <iostream>#include <cstdio>#...原创 2018-12-08 09:01:32 · 186 阅读 · 0 评论 -
HDU-2089 不要62
题目链接这个题算是个入门题,注意拿pre6记录一下上一次是否去了6即可#include <iostream>#include <bits/stdc++.h>using namespace std;int b[21];int dp[21][2];int dfs(int pos,int preok,int pre6){ if(pos==-1) retur...原创 2018-12-08 09:07:50 · 534 阅读 · 1 评论 -
[HDU-4734] F(x)
题目链接这个题十分简单,关键是F(x)定义的那种感觉(jiao)#include <iostream>#include <cstring>#include <cstdio>#include <bits/stdc++.h>using namespace std;int b[21];int l,r;int dp[21][50001...原创 2018-12-08 09:09:46 · 376 阅读 · 0 评论 -
数位dp基本思想
基本思想(lqs学哥深沉嘱咐)数位DP是动态规划里面一种很特殊的形式,因为我对于其他动态规划问题习惯使用迭代的形式,但是对于数位DP更喜欢使用递归的形式,所以对于这种DP单拎出来写一下。其实DP是一种比较玄妙的思想,很难用一种套路的方式表达出来,关键是那种对于给定问题如何去定义“状态”的那种感觉。数位DP其实也是如此,只不过它的状态一般不是那么直接,而是需要一步转化。因为通常的DP都是定义...原创 2018-12-08 09:14:38 · 293 阅读 · 0 评论 -
UVA - 1350 Pinary
题目链接这个是一个二份答案的数位dp,注意开longlong。#include <iostream>#include <bits/stdc++.h>#define LL long longusing namespace std;int b[121];LL dp[121][2][2];int tot,cnt;long long n,L,R,a;LL ...原创 2018-12-08 20:10:02 · 175 阅读 · 0 评论 -
B-number HDU - 3652
题目链接十分简单,与不要62几乎相同,关键是对驱魔(取模)的运算re数组于是就显得十分重要。#include <iostream>#include <bits/stdc++.h>using namespace std;int n;int b[21];int re[21];int dp[21][2][2][14];int dfs(int pos,i...原创 2018-12-08 20:28:41 · 207 阅读 · 0 评论