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. unity3D游戏开发实战原创视频讲座系列7之消消乐游戏开发

    解说文件夹 第一讲  游戏介绍和资源简单介绍 第二讲  游戏场景背景的搭建 第三讲  游戏特效预制体的制作 第四讲  游戏场景前景的显示 第五讲  瓷砖背景块 第六讲  方块的消除 第七讲  方块的交 ...

  2. jeasyui-datagrid使用笔记

    formatter转换ID为值 设置字典缓存 var DictionaryItem = {}; $.post('/Dictionary/GetDictionary/T_RKXD', function ...

  3. The bytes/str dichotomy in Python 3

    The bytes/str dichotomy in Python 3 - Eli Bendersky's website https://eli.thegreenplace.net/2012/01/ ...

  4. 洛谷 P2634 聪聪可可 —— 树形DP / 点分治

    题目:https://www.luogu.org/problemnew/show/P2634 今天刚学了点分治,做例题: 好不容易A了,结果发现自己写的是树形DP...(也不用找重心)(比点分治快) ...

  5. codeforces round #416 div2

    A:暴力模拟 #include<bits/stdc++.h> using namespace std; int a, b; int main() { scanf("%d%d&qu ...

  6. Android.mk添加第三方jar包(转载)

    转自:www.cnblogs.com/hopetribe/archive/2012/04/23/2467060.html LOCAL_PATH:= $(call my-dir)include $(CL ...

  7. Linux特殊符号及基础正则表达式

    第1章 特殊符号 1.1 引号系列 1.1.1 单引号 所见即所得  单引号里面的内容会原封不动的输出 [root@oldboyedu50-lnb ~]# echo 'oldboy $LANG $PS ...

  8. codevs3981动态最大子段和(线段树)

    3981 动态最大子段和  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 题目还是简单一点好... 有n个数,a ...

  9. 数据库mysql原生代码基本操作

    创建表: CREATE TABLE `biao` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '测试表', `createtime` ...

  10. Bitmap与String之间的转换

    /** * 将bitmap转换成base64字符串 * * @param bitmap * @return base64 字符串 */ public String bitmaptoString(Bit ...