Bomb HDU - 3555

求1~n中含有49数的个数

#include<bits/stdc++.h>

#define LL long long
using namespace std; LL T,x,dp[][],shu[]; LL dfs(LL pos,LL x,bool ok,bool limit){
if(!pos) return ok;
if(!limit&&dp[pos][x]) return dp[pos][x];
LL cnt=,up=limit?shu[pos]:;
for(LL i=;i<=up;i++)
{
bool flg=false;
if(x==&&i==) flg=true;
if(ok) flg=true;
cnt+=dfs(pos-,i,flg,limit&&shu[pos]==i);
}
if(!limit) dp[pos][x]=cnt;
return cnt;
} LL slove(LL x){
LL k=;
while(x){
shu[++k]=x%;
x/=;
}
return dfs(k,,,true);
} int main()
{
scanf("%lld",&T);
while(T--){
scanf("%lld",&x);
printf("%lld",slove(x));
if(T) puts("");
}
return ;
}

Bomb HDU - 3555的更多相关文章

  1. Bomb HDU - 3555 (数位DP)

    Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...

  2. Bomb HDU 3555 dp状态转移

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意: 给出一个正整数N,求出1~N中含有数字“49”的数的个数 思路: 采用数位dp的状态转移方程 ...

  3. 数位DP入门(A - 不要62 HDU - 2089 &&B - Bomb HDU - 3555 )

    题目链接:https://cn.vjudge.net/contest/278036#problem/A 具体思路:对于给定的数,我们按照位数进行运算,枚举每一位上可能的数,在枚举的时候需要注意几个条件 ...

  4. Bomb HDU - 3555 数位dp

    Code: #include<cstdio> #include<algorithm> #include<cstring> #include<string> ...

  5. 数位DP入门之hdu 3555 Bomb

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

  6. 递推、数位DP解析(以HDU 2089 和 HDU 3555 为例)

    HDU 2089 不要62 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2089 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人 ...

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

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

  8. HDU 3555 Bomb 数位dp

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

  9. (数位dp)Bomb (hdu 3555)

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

随机推荐

  1. &#39;IOKING&#39; TCP Transmission Server Engine (&#39;云猴&#39;&#169;TCP通讯server引擎)(预告版)

    关键词: IOKING IOCP TCP  Transmission Server Engine Lock Free Interlocked 云猴完毕portTCP通讯server引擎 无锁 原子锁( ...

  2. JPA学习笔记(13)——查询缓存

    使用hibernate的查询缓存 运行下面代码: String jpql = "FROM User u WHERE u.id = ?"; Query query = entityM ...

  3. B1297 [SCOI2009]迷路 矩阵

    这个题我觉得很有必要写一篇博客.首先,我们需要知道,假如一个邻接矩阵只有0/1构成,那么它自己的n次方就是走n步之后的方案数.但这个题还有2~9咋办呢.我们观察发现,这个题只有10个点,而且边权< ...

  4. 必会!Linux文件的管理

    1.1 创建一个目录 /data [root@liuhao ~]# mkdir /data 1.2 查看目录是否创建成功 <可以找到data即为创建成功> [root@liuhao ~]# ...

  5. yii2的form表单用法

    使用表单 本章节将介绍如何创建一个从用户那搜集数据的表单页.该页将显示一个包含 name 输入框和 email 输入框的表单.当搜集完这两部分信息后,页面将会显示用户输入的信息. 为了实现这个目标,除 ...

  6. 数值分析常见算法C++实现

    1.1-有效数字丢失现象观察 #include<bits./stdc++.h> using namespace std; double f1(double x) { )-sqrt(x)); ...

  7. ARM VM安装Linux Diagnostic 2.3扩展

    目前创建的Azure Linux虚拟机默认安装的是LAD 3.0,如果客户有特殊需求,可以通过如下方法安装LAD 2.3 1.在Azure Portal卸载LAD 3.0 2.使用Azure Powe ...

  8. cobbler+kickstart安装笔记

    cobbler+kickstart安装笔记 本文参考老男孩配置:https://blog.oldboyedu.com/autoinstall-cobbler/ centos7:开机如果不启动网卡,需要 ...

  9. AJAX json集合传入Controller后台

    HTML代码 <html> <head> <meta http-equiv="Content-Type" content="text/htm ...

  10. ACM_求交集

    求交集 Time Limit: 2000/1000ms (Java/Others) Problem Description: 输入集合A和B,按大小顺序输出A和B的交集. Input: 输入包含多组测 ...