hdu 3555 Bomb 【数位DP】】的更多相关文章

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) 问题描述 The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bo…
给出n,问所有[0,n]区间内的数中,不含有49的数的个数 数位dp,记忆化搜索 dfs(int pos,bool pre,bool flag,bool e) pos:当前要枚举的位置 pre:当前要枚举的位置的前面是否为4 flag:枚举当前时,这个数的49时候被算过了 e:当前位置是否可以随便取值 dp[pos][pre][flag] #include<cstdio> #include<cstring> #include<algorithm> #include<…
链接: https://vjudge.net/problem/HDU-3555 题意: The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number sequence includes…
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number sequence includes the sub-sequence "49&…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 15372    Accepted Submission(s): 5563 Problem Description The counter-terrorists f…
题意 求区间[1,n]内含有相邻49的数. 思路 比较简单的按位DP思路.这是第一次学习记忆化搜索式的数位DP,确实比递推形式的更好理解呐,而且也更通用~可以一般化: [数位DP模板总结] int dfs(int pos, int pre, int flag, bool limit) { if (pos == -1) return flag==target_flag; if (!limit && ~dp[pos][pre][flag]) return dp[pos][pre][flag];…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 19122    Accepted Submission(s): 7068 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorist…
//hdoj 3555 //2013-06-27-16.53 #include <stdio.h> #include <string.h> __int64 dp[21][3], n; int len, bit[21]; //dp[i][0] 长度为i 包含49的个数 //dp[i][1] 长度为i没有49但以9开头的 //dp[i][2] 长度为i 没有49 void init() { dp[0][2] = 1; for (int i = 1; i < 20; i++) {…
hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区间范围内的数,此题是含有:正好相反,对于 "不要62"只是用第二位表示首位数字,这一题呢? 看转化:易知一定要要知道首位是9的个数,才能在前面加4得到 '49',但是什么状态能从不含 '49'转移到含 '49'?直接在不含'49'前加9,那么就出现了三个状态之间的递推转化,从而推出了第二维…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the curre…