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]的更多相关文章

  1. 数位DP入门之hdu 3555 Bomb

    hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区 ...

  2. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  3. hdu 3555 Bomb(不要49,数位DP)

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submi ...

  4. HDU 3555 Bomb 数位dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...

  5. HDU 3555 Bomb(数位DP模板啊两种形式)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found ...

  6. hdu 3555 Bomb 【数位DP】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意:上一题是不要62 这个是"不要49" 代码: #include < ...

  7. HDU 3555 Bomb(数位DP)

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Subm ...

  8. 数位dp整理 && 例题HDU - 2089 不要62 && 例题 HDU - 3555 Bomb

    数位dp: 数位dp是一种计数用的dp,一般就是要统计一个区间[li,ri]内满足一些条件数的个数.所谓数位dp,字面意思就是在数位上进行dp.数位的含义:一个数有个位.十位.百位.千位......数 ...

  9. HDU 3555 Bomb 数位DP 入门

    给出n,问所有[0,n]区间内的数中,不含有49的数的个数 数位dp,记忆化搜索 dfs(int pos,bool pre,bool flag,bool e) pos:当前要枚举的位置 pre:当前要 ...

  10. 动态规划晋级——HDU 3555 Bomb【数位DP详解】

    转载请注明出处:http://blog.csdn.net/a1dark 分析:初学数位DP完全搞不懂.很多时候都是自己花大量时间去找规律.记得上次网络赛有道数位DP.硬是找规律给A了.那时候完全不知数 ...

随机推荐

  1. Egret入门学习日记 --- 第三篇 (书中 3.4 内容)

    第三篇 (书中 3.4 内容) 今天还是要把昨天项目运行后,EXML文件里的界面没有出现的问题解决了才行. 去了群里,没人回.去了官网看文档,看不懂. 不过倒是看到了一个好东西: 还挺便宜啊,一个月要 ...

  2. 最新 中至数据java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.中至数据等10家互联网公司的校招Offer,因为某些自身原因最终选择了中至数据.6.7月主要是做系统复习.项目复盘.Leet ...

  3. Spring 使用日期类型

    1. 数据层数据类型依赖包  java.time.LocalDate 2.pom.xml添加依赖 <dependency> <groupId>org.thymeleaf.ext ...

  4. 关于React的脚手架

    Rewire你的应用 https://ant.design/docs/react/use-with-create-react-app-cn create-react-app (官方脚手架 简称cra) ...

  5. 冲刺Noip2017模拟赛8 解题报告——五十岚芒果酱

    1.鼎纹 [问题描述] 据说鼎纹的 种制造 式是 铜模印出来的,这是我国古代劳动 智慧 的结晶.铜模印过的地 ,会留下深深的印记,经过时间的炼化,洗 练成历史的遗存. 聪明的古代劳动人民拥有一个 a ...

  6. JavaScript、TypeScript、ES6三者之间的联系和区别

    ES6是什么 ECMAScript 6.0(以下简称ES6)是JavaScript语言(现在是遵循ES5标准)的下一代标准,已经在2015年6月正式发布了.它的目标,是使得JavaScript语言可以 ...

  7. Flink SQL项目实录

    一.Flink SQL层级 为Flink最高层的API,易于使用,所以应用更加广泛,eg. ETL.统计分析.实时报表.实时风控等. Flink SQL所处的层级: 二.Flink聚合: 1.Wind ...

  8. java23种设计模式之九: 抽象工厂方法模式

    一.抽象工厂定义 上一讲我们说了一下工厂方法,那么我们如何对工厂进行抽象. 因为工厂是生产产品的,现在我们需要工厂抽象,只生产抽象产品,不生产具体的产品,这同时也体现了java的多态. 现在有2个抽象 ...

  9. 图数据库neo4j添加算法包

    1. 从https://github.com/neo4j-contrib/neo4j-graph-algorithms/releases下载相应版本jar包,放到 C:\Users\Administr ...

  10. java 中的容器(札记)

    创建容器向上转型为接口的时候,有时候,并不是一定可行的,因为有的实现类,在接口的基础添加了自己的方法:比如:List 接口下面的 LinkedList 自己定义了一些方法 : Arrays.asLis ...