hud 3555 Bomb 数位dp】的更多相关文章

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…
题目链接: 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<…
//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++) {…
链接: 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…
题目链接:http://acm.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): 18739    Accepted Submission(s): 6929 Problem Description The counter-terrorists found…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 7921    Accepted Submission(s): 2778 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 简单的数位DP入门题目 思路和hdu2089基本一样 直接贴代码了,代码里有详细的注释 代码: #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; ][]; void init() { dp[][]=;dp[][]=;dp[…
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 16713 Accepted Submission(s): 6128 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists impr…
题目传送门 Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 23853    Accepted Submission(s): 8990 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terr…
题意 求区间[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];…
---恢复内容开始--- 不能有49 数位dp模板题: #include<bits/stdc++.h> using namespace std; //input by bxd #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define repp(i,a,b) for(int i=(a);i>=(b);--i) #define RI(n) scanf("%d",&(n)) #define RII(n,m) sc…
题目描述 求 1~N 内包含数位串 “49” 的数的个数. 输入 The first line of input consists of an integer T (1 <= T <= 10000), indicating the number of test cases. For each test case, there will be an integer N (1 <= N <= 2^63-1) as the description.The input terminates…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 16362    Accepted Submission(s): 5979 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 思路分析:该问题要求求解1—N中的数中含有49的数的个数,可以使用DFA来递推dp公式:详细解释点击链接查看: 代码如下: #include <cstdio> #include <cstring> #include <iostream> using namespace std; + ; ]; int digit[MAX_N]; int NextState(int cu…
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", the power of the…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 19698    Accepted Submission(s): 7311 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
题目链接: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…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 11804    Accepted Submission(s): 4212 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorist…
转载请注明出处:http://blog.csdn.net/a1dark 分析:初学数位DP完全搞不懂.很多时候都是自己花大量时间去找规律.记得上次网络赛有道数位DP.硬是找规律给A了.那时候完全不知数位DP为何物.不过还是有很多时候要用数位DP.比如当一个数字超过了数组承受的极限.不能再打表AC.先看这道题.首先划分状态.然后初始化.最后从高位向低位状态转移.代码含详解 //dp[len][0]表示长度为len不含49的数量 //dp[len][1]表示长度为len不含44但以9开头的数字的数量…
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,那么就出现了三个状态之间的递推转化,从而推出了第二维…
数位dp: 数位dp是一种计数用的dp,一般就是要统计一个区间[li,ri]内满足一些条件数的个数.所谓数位dp,字面意思就是在数位上进行dp.数位的含义:一个数有个位.十位.百位.千位......数的每一位就是数位.一般都通过dfs来递归找寻. 数位dp与dfs爆搜之间的区别就是前者会记录状态以便优化下一次寻找的时间(也就是记忆化操作) 数位dp操作: 例如给你一个区间[12,12345],你需要找到这个区间内满足条件的数的个数.这个时候我们一般都是先找[0,12345]这个区间满足条件数的个…
http://acm.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): 7316    Accepted Submission(s): 2551 Problem Description The counter-terrorists found a time…
HDU 2089 不要62 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2089 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众.不吉利的数字为所有含有4或62的号码.例如:62315 73418 88914都属于不吉利号码.但是,6115…
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", the power of the…
最基本的一类数位dp题,题目大意一般是在a~b的范围,满足某些要求的数字有多少个,而这些要求一般都是要包含或者不包含某些数字,或者一些带着数字性质的要求,一般来说暴力是可以解决这一类问题,可是当范围非常大时,暴力明显会超时,这时便是需要把它转化为一类dp问题,这就是数位dp.像一个数1234567890,直接把它暴力的话,那它就是一个1e9级别的数,可是把它一个数位一个数位的话,那它就是1位是0,2为是9,一直到10位是1,一共才10位的长度,明显就比暴力明朗多了. 由于我也是刚接触不久,还没有…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题目大意:求 \([1,n]\) 范围内有多少数包含"49". 解题思路: 这个问题我们可以分两种解法来考虑:第一种是求不包含"49"的数的数量,用后减一下:另一种就是直接求包含"49"的数的数量. 解法1:求多少数不包含"49" 这种方法我们先通过数位DP求出 \([0,n]\) 区间范围内有多少数不包含"49&…
Description 题意就是找0到N有多少个数中含有49. \(1\leq N \leq2^{63}-1\) Solution 数位DP,与hdu3652类似 \(F[i][state]\)表示位数为i,包含49状态为state时的方案数 注意开\(long long\) Tips 注意N范围很大,位数不止10位!! Code #include <cstdio> #include <cstring> #define ll long long int d[20]; ll dp[2…