题意:给定一个闭区间,求区间内有多少数中含“49”

/*
dp[i][j]表示i位数以j为最高位位中的所有不符合数的个数。
然后把数字拆分,乱搞即可。
*/
#include<cstdio>
#include<iostream>
#define lon long long
using namespace std;
lon dp[][];
void init(){
dp[][]=;
for(int i=;i<=;i++)
for(int j=;j<=;j++)
for(int k=;k<=;k++)
if(!(j==&&k==))
dp[i][j]+=dp[i-][k];
}
lon solve(lon n){
int a[],len=;
while(n){
a[++len]=n%;
n/=;
}
a[len+]=;
lon ans=;
for(int i=len;i;i--){
for(int j=;j<a[i];j++)
if(!(a[i+]==&&j==))
ans+=dp[i][j];
//当高位出现49时,低位就不用再计算了
if(a[i]==&&a[i+]==) break;
}
return ans;
}
int main(){
init();
int T;scanf("%d",&T);
while(T--){
lon x;
scanf("%I64d",&x);
printf("%I64d\n",x+-solve(x+));
}
return ;
}

Bomb(hdu 3555)的更多相关文章

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

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

  2. 2道acm编程题(2014):1.编写一个浏览器输入输出(hdu acm1088);2.encoding(hdu1020)

    //1088(参考博客:http://blog.csdn.net/libin56842/article/details/8950688)//1.编写一个浏览器输入输出(hdu acm1088)://思 ...

  3. Bestcoder13 1003.Find Sequence(hdu 5064) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b ...

  4. 2013 多校联合 F Magic Ball Game (hdu 4605)

    http://acm.hdu.edu.cn/showproblem.php?pid=4605 Magic Ball Game Time Limit: 10000/5000 MS (Java/Other ...

  5. (多线程dp)Matrix (hdu 2686)

    http://acm.hdu.edu.cn/showproblem.php?pid=2686     Problem Description Yifenfei very like play a num ...

  6. War Chess (hdu 3345)

    http://acm.hdu.edu.cn/showproblem.php?pid=3345 Problem Description War chess is hh's favorite game:I ...

  7. 2012年长春网络赛(hdu命题)

    为迎接9月14号hdu命题的长春网络赛 ACM弱校的弱菜,苦逼的在机房(感谢有你)呻吟几声: 1.对于本次网络赛,本校一共6名正式队员,训练靠的是完全的自主学习意识 2.对于网络赛的群殴模式,想竞争现 ...

  8. BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

    Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  9. BestCoder Round #68 (div.2) geometry(hdu 5605)

    geometry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

随机推荐

  1. 第13章 Swing程序组件----常用布局管理器

    在Swing中,每个组件在容器中都有一个具体的位置和大小,而在容器中摆放各种组件时很难判断其具体位置和大小.布局管理器提供了Swing组件安排.展示在容器中的方法及基本的布局功能. Swing提供的常 ...

  2. 【嵌入式linux】(第三步):安装串口终端 (ubuntu安装minicom串口终端)

    1.前言 我使用的是USB转串口,芯片是PL2303,貌似ubuntu自带了PL2303的USB驱动,可以直接使用,其它的USB转串口的没试过. 2.minicom安装 在终端中输入 : sudo a ...

  3. svg都快忘了,复习一下

    http://www.360doc.com/content/07/0906/21/39836_724430.shtml

  4. 转 layout_weight体验(实现按比例显示)

    http://www.cnblogs.com/zhmore/archive/2011/11/04/2236514.html 在android开发中LinearLayout很常用,LinearLayou ...

  5. 转:移植SlidingMenu Android library,和安装example出现的问题解决

    很多项目都用到类似左侧滑动菜单的效果,比如facebook,evernote,VLC for android等等,这很酷 源代码可以从GitHub的https://github.com/jfeinst ...

  6. Java BufferedReader、InputStream简介

    InputStream  数据流类 一般来说,就是将字符串.管道数据(socket通倒).文件.字节等转换为输入流,以流的方式去读取: 但是inputstream的读取速率较低,为了提高读取速率,一般 ...

  7. Eclipse/MyEclipse 最最常用的快捷键

    F 键类 F2 显示详细信息 F3 跳到声明或定义的地方 Ctrl + 键类 Ctrl+1 快速修复 ( 最经典的快捷键 , 就不用多说了 ) Ctrl+D 删除当前行 Ctrl+E 快速显示当前 E ...

  8. CSS中margin和position:relative的定位问题

    一.代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  9. hdu1915

    对于图的东西总是一筹莫展,没办法,还是翻出以前的基础题来看看,然后慢慢分析吧.路漫漫其修远兮,吾将上下而求索…… void bfs(int x,int y){ for(int k=0;k<8;k ...

  10. Transport layer and Network layer

    http://stackoverflow.com/questions/13333794/networking-difference-between-transport-layer-and-networ ...