
ACM_DP_数位DP
文章平均质量分 69
9974
这个作者很懒,什么都没留下…
展开
-
CodeForces 215E 数位DP
#include #include #include #include using namespace std;#define LL long longLL dp[66];int dig(LL n) { int s = 0; while(n) {s++; n >>=1;} return s;}LL f(int len, int t, LL n, bool lim) { i原创 2013-04-15 14:44:04 · 1257 阅读 · 0 评论 -
UESTC 1307 数位DP (递归 or 非递归)
非递归#include #include #include #include using namespace std;int l, r;int dp[33][11];int abs(int a, int b) { a -= b; return a > 0 ? a : -a;}void init() { int i, j, k; for(i = 0; i <原创 2013-04-15 14:50:37 · 1314 阅读 · 0 评论 -
URAL 1057 数位DP(递归)
递归#include #include #include #include using namespace std;int k, b, l, r;int dp[66][66][66];int a[66];int dfs(int len, int cnt, bool lim) { if(!len) return cnt == k; if(!lim && ~dp[len][cn原创 2013-04-15 14:51:36 · 1247 阅读 · 0 评论 -
数位DP入门题两枚
light OJ 1140 - How Many Zeroes? 题意: 给你两个数 m,n (m 思路:当然我们只要函数(f(x))计算0-x之间0的个数,那答案就是 f(n) - f(m-1)如何完成这一函数呢?1. 我们先预处理出dp[i][j] (表示以首位为j,数的长度为i的所有数的0的个数)2. 数位处理: 给你一个数 n 如 2034 数位为4原创 2013-01-15 03:04:55 · 1217 阅读 · 0 评论 -
CodeForces 55D 数位DP 能被它自身数位上的所有数整除
#include #include #include #include using namespace std;#define LL __int64int id, mp[2555];LL dp[22][55][2525];int a[22];int gcd(int a, int b) { return b ? gcd(b, a%b) : a;}int LCM(int原创 2013-04-13 10:28:38 · 1264 阅读 · 0 评论 -
hdu 4352 数位DP
#include #include #include #include using namespace std;#define LL __int64LL l, r;int k;int a[25];LL dp[25][11][(1<<10)+3];LL dfs(int len, int num, int zt, int lim) { if(!len) return num原创 2013-04-15 14:53:22 · 1110 阅读 · 0 评论 -
light OJ 1068 数位DP
#include #include #include #include using namespace std;int a[33];int dp[33][103][103];int k;int dfs(int len, int mod1, int mod2, bool lim) { if(!len) return !mod1 && !mod2; if(!lim &&原创 2013-04-15 14:55:25 · 1381 阅读 · 0 评论 -
Codeforces 258B 数位DP
递归#include #include #include #define LL __int64const LL mod = 1000000007;LL dp[11], ans;int len;char a[11];void add(int dep, int dig, int num){ if(!dep) { dp[dig] += num;原创 2013-03-17 19:54:50 · 1273 阅读 · 0 评论 -
light OJ 1205 数位DP
#include #include #include #include using namespace std;#define LL long longLL l, r;int a[66];LL dp[66][66];LL dfs(int len, int l, int r, bool lim, bool ok) { if(l < r) return !lim || lim原创 2013-04-15 14:54:33 · 1382 阅读 · 0 评论 -
POJ 3252 数位DP
#include #include #include #include using namespace std;int dp[33][33][33];int a[33];int dfs(int len, int one, int zero, bool lim) { if(!len) return zero >= one; if(!lim && ~dp[len][zer原创 2013-04-15 14:49:00 · 1132 阅读 · 0 评论 -
hdu 3709 数位DP
#include #include #include #include using namespace std;#define LL __int64int a[22];LL dp[22][22][2066];LL dfs(int len, int idx, LL sum, bool lim) { if(len == -1) return !sum; if(sum < 0) re原创 2013-04-15 06:48:10 · 1033 阅读 · 0 评论 -
hdu 3555 数位DP
#include #include #include #include using namespace std;#define LL __int64LL n;/* * 0 不含49 * 1 9开头不含49 * 2 含49 */LL dp[22][3];void init() { int i, j, k; dp[0][0] = 1; for(i = 0; i < 20原创 2013-04-15 14:46:16 · 961 阅读 · 0 评论 -
HDU 3652 数位DP
递归:#include #include #include #include using namespace std;int a[11];int n;/* * 0 包含13 * 1 不包含13,但以3结尾 * 2 不包含13,不以3结尾 */int dp[11][3][15];int dfs(int len, int pre, int mod, bool lim原创 2013-03-17 20:13:49 · 882 阅读 · 0 评论 -
Codeforces 259 D 数位DP + 搜索
http://www.codeforces.com/contest/259/problem/D数位DP可以写成递归和非递归两种:递归:#include #include #include #define LL __int64const LL mod = 1000000007;LL dp[11], ans;int len;char a[11];void add(in原创 2013-01-16 15:16:06 · 975 阅读 · 0 评论 -
HDU 2089 数位DP
#include #include #include #include using namespace std;int l, r;/* * 0 不包含62 * 1 以2开头不包含62 * 2 包含62 */int dp[11][3], f[11];void init() { int i, j; f[0] = 1; for(i = 0; i <= 9; i++)原创 2013-04-15 14:45:14 · 1123 阅读 · 0 评论 -
SPOJ 1128 数位DP
#include #include #include #include using namespace std;#define LL long longint dp[33][33];void init() { int i, j; dp[0][0] = 1; for(i = 1; i <= 32; i++) for(j = 0; j <= i; j++) { dp[i]原创 2013-04-15 14:55:57 · 1170 阅读 · 0 评论 -
HDU 3886 数位DP
#include #include #include #include #include using namespace std;const int mod = 100000000;string c, s, l, r;int tot;int dp[133][13][133];void add(int &a, int b) { a += b; if(a >= mo原创 2013-04-15 14:53:51 · 1230 阅读 · 0 评论 -
2008-2009 ACM-ICPC Northeastern European Regional Contest (NEERC 08) (2013区域赛练习)
比赛A了B, G,H,I, 赛后我独自整理了F,J, 还有A题貌似可以做,可惜没时间,下次再整理吧。讲一下J和F的思路, 还有贴J和K的代码J :其实就是把字母映射分成元音和辅音两组就可以了, 那么我们暴力dfs把26个字母分成2组的状态,然后根据输入的串相邻位置不能是同一组的把一大堆无用状态删去,然后找到一个有用的就停,修改一下即可。注意:每个单词有可能用空行隔开。F:数位统原创 2013-11-30 21:39:26 · 2288 阅读 · 1 评论