hdu3555】的更多相关文章

[HDU3555]Bomb 试题描述 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.hdu.edu.cn/showproblem.php?pid=3555 (题目链接) 题意 求区间${[1,n]}$含有49的数的个数. Solution 数位dp,先求出不含49的,再减一下就好了. 细节 LL 代码 // hdu3555 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #…
题意就是找0到n有多少个数中含有49.数据范围接近10^20 DP的状态是2维的dp[len][3]dp[len][0] 代表长度为len不含49的方案数dp[len][1] 代表长度为len不含49但是以9开头的数字的方案数dp[len][2] 代表长度为len含有49的方案数 状态转移如下dp[i][0] = dp[i-1][0] * 10 - dp[i-1][1];  // not include 49  如果不含49且,在前面可以填上0-9 但是要减去dp[i-1][1] 因为4会和9构…
数位dp简介: 数位dp常用于求区间内某些特殊(常关于数字各个数位上的值)数字(比如要求数字含62,49): 常用解法: 数位dp常用记忆化搜索或递推来实现: 由于记忆化搜索比较好写再加上博主比较蒟,所以本文基本只介绍用记忆化搜索实现的数位dp: 记搜写法: 一般记搜写法会暴力搜索每个数的每一位,如果满足特征就加入答案: 而搜索中或搜完后用一个dp数组来存某一区间的特殊数的数量,防止多次重复搜索TLE: 空口说比较苍白无力,举个例子:比如要在1到r中找含49(4和9要连在一起)的特殊数的数量:…
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…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 13181    Accepted Submission(s): 4725 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) Total Submission(s): 7316    Accepted Submission(s): 2551 Problem Description The counter-terrorists found a time…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 15025    Accepted Submission(s): 5427 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
基本的数位dp #include <cstdio> #include <cstring> using namespace std; #define D(x) x ; long long n; int f[MAX_DIGIT]; ][][]; void to_digits(long long a) { ; i < MAX_DIGIT; i++) { f[i] = a % ; a /= ; } } long long dfs(int digit, bool less, bool…
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…
为了搞SCOI的几道题先做水数位.之前听过课,半懂不懂吧,现在清楚了些. 这类题一般满足区间减法,即只需要我们求出(1,n)即可,然后打表也是为了sovle(DataType)服务.先想好怎么计算,再去想怎么打表.计算是一般存在这样的问题,就是比如n=abcdef,当a=6时,6开头的不能全算,那就只能先算1~5,然后理解为把6摆好,算下一位,这样我们发现,这个函数是没有包含n这个数的,所以调用是要调用sovle(n+1) 不要62 Problem Description 杭州人称那些傻乎乎粘嗒…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意:求区间[a,b]内包含有'49'的数的总个数. 分析:dp[pos][0]表示到第pos位没有包含49,后面1~pos-1位任意填时的总个数,dp[pos][1]表示到第pos位时前一位刚好是'4',后面任意填时的总个数,dp[pos][2]表示已经包含49后面任意填的总个数... #include <cstdio> #include <cstring> #include…
题目链接: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[…
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…
/* dp[i][0|1|2]:没有49的个数|最高位是9,没有49的个数|有49的个数 dp[i][0]=10*dp[i-1][0]-dp[i-1][1] dp[i][1]=dp[i-1][0] dp[i][2]=10*dp[i-1][2]+dp[i-1][1] */ #include<bits/stdc++.h> using namespace std; #define ll long long ll dp[][],n,t; void init(){ dp[][]=; ;i<=;i+…
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…
题目描述 求 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): 11029    Accepted Submission(s): 3916 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
题目:区间的数里面有49的个数 分析: dp[pos][0]:长度为pos的数中,不包含49的,前一位不为4的有多少个:dp[pos][1]:长度为pos的数中,不包含49的,前一位为4的有多少个:dp[pos][2]:长度为pos的数中,包含49的有多少个: 一开始我是打算先算不满足的,在算满足的:结果不行,可能这样算出来的数太大了所以不行吧: 通过这道题可以更加理解了(不要62)这个题目的sta 的表示 , 原来如此呀 #include<stdio.h> #include<strin…
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…
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…
入门...还在学习中,先贴一发大牛博客 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题目大意: 给一个数字n,范围在1~2^63-1,求1~n之间含有49的数字有多少个. 思路: 经典的数位DP,学习了一下,看的别人的代码:http://www.cnblogs.com/luyi0619/archive/2011/04/29/2033117.html 状态转移: dp[i][0]代表长度为 i 并且不含有49的数字的个数: dp[i][1…
题目链接: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): 10649    Accepted Submission(s): 3758 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists…
题目传送门 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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题目大意:求 \([1,n]\) 范围内有多少数包含"49". 解题思路: 这个问题我们可以分两种解法来考虑:第一种是求不包含"49"的数的数量,用后减一下:另一种就是直接求包含"49"的数的数量. 解法1:求多少数不包含"49" 这种方法我们先通过数位DP求出 \([0,n]\) 区间范围内有多少数不包含"49&…
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…
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 current number sequence includes the sub-sequence "49&quo…
由简单到稍微难点. 从网上搜了10到数位dp的题目,有几道还是很难想到的,前几道基本都是模板题,供入门用. 点开即可看题解. hdu3555 Bomb hdu3652 B-number hdu2089 不要62 hdu4734 F(x) hdu4389 X mod f(x) ural1057 Amount of Degrees hdu4352 XHXJ's LIS CodeForces 55D Beautiful numbers zoj3416 Balanced Number VJ专题题目链接…
ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜鸟之作,大牛勿喷,如有不当或补充之处,欢迎指出. 本建议书分为三个阶段,大一.大二.大三.大四暂没整理,一方面是大四要面临考验和找工作的问题,坚持继续acm的很少,另一方面,本人还没大四…… 下面以个人经验分析一下这三个阶段建议学习的内容和具体的训练计划. 正文: 大一(第一阶段): 大一是时间最充…