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. 机器学习算法K-NN的一个使用实例:预测一个人是否患有糖尿病 (KNN-Predict whether a person will have diabetes or not )

    学习中...不断更新. 在糖尿病人的数据库中有几列是不能为0的 比如葡萄糖 胰岛素 身体指数和皮肤厚度.所以在数据预处理阶段需要对这些列的数据进行替换. remeber we did 12 minus ...

  2. [转载]oracle xml操作

    /*=====================生成\修改xml========================= */ --xmlelement多个标签层级 SELECT XMLELEMENT(&qu ...

  3. annotation @Retention@Target

    一.注解:深入理解JAVA注解 要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法. 1.元注解(meta-a ...

  4. [转帖]Intel要提供2.5G的消费级以太网 价格2.4刀

    千兆网已成过去!Intel将全面普及2.5Gbps以太网 https://news.cnblogs.com/n/641736/ 硬件发展突飞猛进 投递人 itwriter 发布于 2019-10-02 ...

  5. K8S从入门到放弃系列-(5)kubernetes集群之kube-apiserver部署

    摘要: 1.kube-apiserver为是整个k8s集群中的数据总线和数据中心,提供了对集群的增删改查及watch等HTTP Rest接口 2.kube-apiserver是无状态的,虽然客户端如k ...

  6. Java面试题代码篇

    1.统计字符串中的各种字符的个数并对其排序 package JavaMianSiTest; public class TongJIZiFu { public static void main(Stri ...

  7. JVM —— 类文件结构(上)

    一.概述 实现语言无关性的基础仍然是虚拟机和字节码存储格式.java虚拟机不和包括java在内的任何语言绑定,它只与“Class文件”这种特定的二进制文件格式所关联,Class文件中包含了java虚拟 ...

  8. (四)Resquest 知识点总结 (来自那些年的笔记)

    目录 URL和URI的区别 获取URL.URI 什么是HttpServletResquest 获取请求头中字段的内容 获取请求信息的数据 将客户机的请求变为一个流返回 常用的方法 request乱码问 ...

  9. Python笔记day20-面向对象

    目录 面向对象 1 装饰器 1.1 装饰器是什么? 1.2 装饰器 2 面向对象 (Object Oriented) 简称OO 2.1 面向对象相关术语 2.2 类和对象 2.3 类和对象的实现和书写 ...

  10. 20190924-LeetCode解数独题目分享

    解决数独 题目描述 编写一个程序,通过已填充的空格来解决数独问题. 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次. 数字 1-9 在每一列只能出现一次. 数字 1-9 在每一个以 ...