【数位DP-板子题目】HDU-3555-Bomb- [只要49]
Bomb Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): 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 to N. If the current number sequence includes the sub-sequence "", the power of the blast would add one point.
Now the counter-terrorist knows the number N. They want to know the final points of the power. Can you help them? Input
The first line of input consists of an integer T ( <= T <= ), indicating the number of test cases. For each test case, there will be an integer N ( <= N <= ^-) as the description. The input terminates by end of file marker. Output
For each test case, output an integer indicating the final points of the power. Sample Input Sample Output Hint
From to , the numbers that include the sub-sequence "" are "","","","","","","","","","","","","","","",
so the answer is .
题解:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <string.h>
#include<set>
using namespace std;
#define inf 0x3f3f3f3f
const double pi=acos(-1.0); ///数位DP,只要49
#define ll long long
#define lson root<<1
#define rson root<<1|1
const ll mod = ;
#define ull unsigned long long
ll digit[];
ll dp[][];
///limit表示是否受限,最初进行的时候必定受限!
ll Cul(int len,bool if4,bool limit){ if(len<)return ;
if(!limit&&dp[len][if4]!=-)return dp[len][if4];
int up_bound=(limit==)?digit[len]:;
ll ans=;
for(int i=;i<=up_bound;i++)
{
if(if4&&i==)
continue;
ans+=Cul(len-,i==,limit&&i==digit[len]);
}
dp[len][if4]=ans;
return ans;
} ll solve(ll n){
int k=;
while(n){
digit[++k]=n%;
n/=;
}
memset(dp,-,sizeof(dp));
return Cul(k,false,true);
} int main(){ ll n,T;
cin>>T;
while(T--){
scanf("%lld",&n);
printf("%lld\n",n-solve(n)+); } return ;
}
【数位DP-板子题目】HDU-3555-Bomb- [只要49]的更多相关文章
- 数位DP入门之hdu 3555 Bomb
hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区 ...
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- hdu 3555 Bomb(不要49,数位DP)
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- HDU 3555 Bomb 数位dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...
- HDU 3555 Bomb(数位DP模板啊两种形式)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found ...
- hdu 3555 Bomb 【数位DP】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意:上一题是不要62 这个是"不要49" 代码: #include < ...
- HDU 3555 Bomb(数位DP)
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Subm ...
- 数位dp整理 && 例题HDU - 2089 不要62 && 例题 HDU - 3555 Bomb
数位dp: 数位dp是一种计数用的dp,一般就是要统计一个区间[li,ri]内满足一些条件数的个数.所谓数位dp,字面意思就是在数位上进行dp.数位的含义:一个数有个位.十位.百位.千位......数 ...
- HDU 3555 Bomb 数位DP 入门
给出n,问所有[0,n]区间内的数中,不含有49的数的个数 数位dp,记忆化搜索 dfs(int pos,bool pre,bool flag,bool e) pos:当前要枚举的位置 pre:当前要 ...
- 动态规划晋级——HDU 3555 Bomb【数位DP详解】
转载请注明出处:http://blog.csdn.net/a1dark 分析:初学数位DP完全搞不懂.很多时候都是自己花大量时间去找规律.记得上次网络赛有道数位DP.硬是找规律给A了.那时候完全不知数 ...
随机推荐
- (CVE-2017-8464)LNK文件远程代码执行
漏洞详细 北京时间2017年6月13日凌晨,微软官方发布6月安全补丁程序,“震网三代” LNK文件远程代码执行漏洞(CVE-2017-8464)和Windows搜索远程命令执行漏洞(CVE-2017- ...
- 解决安装eclipse时出现"Failed to load JNI shared library"
下午远程帮别人弄了很久的eclipse,安装时老是出现如图的字样 最后在安装配置文件中找到问题所在,这个最新版本的eclipse需要jdk1.8的环境,由于系统的jdk是1.7,版本过低从而导致安装失 ...
- 原装win8系统电脑崩溃问题解决
原装win8系统电脑崩溃问题解决 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ 说明:之所以撰写本篇关于win8原装系统电脑崩溃的博文,一是要吐槽一下原装w ...
- 电脑磁盘分区助手:DiskGenius磁盘管理与数据恢复软件
百度搜索DiskGenius自行下载
- Alt+~,Alt+Tab
Alt+~可以很方便的切换同一个软件中的内容. Alt+Tab可以很方便的切换不同软件之间的内容. 熟练使用,很方便.
- Java 文件下载工具类
Java 文件下载工具类 import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static Logger logger = ...
- sqlserver2005版本的mdf文件,还没有log文件,
https://www.cnblogs.com/wanglg/p/3740129.html 来自此文 仅做备忘 感谢提供信息让我处理好此问题 sqlserver mdf向上兼容附加数据库(无法打开 ...
- 【CodeForces】1172E. Nauuo and ODT
题解 看了一遍题解(以及代码)但是没写代码-- 后来做梦的时候忽然梦到了这道题--意识到我需要补一下-- 这道题就是,对于每种颜色,把没有染成这种颜色的点标成黑点,然后计算每个联通块的平方 然后每个点 ...
- java日志框架系列(7):logback框架Layout详解
1.Layout layout从字面意思来看就是排版.布局咯. 1.Layout简介 功能:负责把事件转换成字符串.Layout接口的格式化方法doLayout()负责将代表任何类型的事件的转换成一个 ...
- Word 查找替换高级玩法系列之 -- 查找文档中的叠字
叠字,顾名思义,就是重复出现,叠加在一起的文字,多多少少.点点滴滴等都属于这类范畴.而当Word文档中出现这类文字的时候我们应该怎么鉴别呢?如何找到这些叠字? 李清照的<声声慢>一词相信大 ...