Bomb

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 18659    Accepted Submission(s):
6891

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 1 to N. If the current number sequence includes the
sub-sequence "49", 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 (1
<= T <= 10000), indicating the number of test cases. For each test case,
there will be an integer N (1 <= N <= 2^63-1) 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
3
1
50
500
 
Sample Output
0
1
15

Hint

From 1 to 500, the numbers that include the sub-sequence "49" are "49","149","249","349","449","490","491","492","493","494","495","496","497","498","499",
so the answer is 15.

 
Author
fatboy_cw@WHU
 
Source
 
思路同hdu2089 http://www.cnblogs.com/L-Memory/p/7189656.html
 
#include<iostream>
#include<cstdio>
#include<cstring> using namespace std;
long long f[][],dig[];
long long ans,len,n,m,t; void init()
{
ans=;len=;
memset(f,,sizeof f);
f[][]=;
for(long long i=;i<=;i++)
for(long long j=;j<;j++)
for(long long k=;k<;k++)
if(!(j== && k==)) f[i][j]+=f[i-][k];
} long long solve(long long x)
{
while(x)
{
dig[++len]=x%;
x/=;
}dig[len+]=;
for(long long i=len;i;i--)
{
for(long long j=;j<dig[i];j++)
if(!(dig[i+]== && j==)) ans+=f[i][j];
if(dig[i]== && dig[i+]==) break;
}return ans;
} int main()
{
cin>>t;
while(t--)
{
cin>>n;
init();
cout<<n+-solve(n+)<<endl;
}
return ;
}

hdu3555Bomb(数位dp)的更多相关文章

  1. 数位dp真·浅谈 By cellur925

    预警:由于是从$Vergil$学长那里和$Mathison$大神那里学来的,所以清一色记忆化搜索!qwq 巨佬的数位dp讲解(未来的咕咕日报头条): https://www.luogu.org/blo ...

  2. 【BZOJ1662】[Usaco2006 Nov]Round Numbers 圆环数 数位DP

    [BZOJ1662][Usaco2006 Nov]Round Numbers 圆环数 Description 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...

  3. bzoj1026数位dp

    基础的数位dp 但是ce了一发,(abs难道不是cmath里的吗?改成bits/stdc++.h就过了) #include <bits/stdc++.h> using namespace ...

  4. uva12063数位dp

    辣鸡军训毁我青春!!! 因为在军训,导致很长时间都只能看书yy题目,而不能溜到机房鏼题 于是在猫大的帮助下我发现这道习题是数位dp 然后想起之前讲dp的时候一直在补作业所以没怎么写,然后就试了试 果然 ...

  5. HDU2089 不要62[数位DP]

    不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  6. 数位DP GYM 100827 E Hill Number

    题目链接 题意:判断小于n的数字中,数位从高到低成上升再下降的趋势的数字的个数 分析:简单的数位DP,保存前一位的数字,注意临界点的处理,都是套路. #include <bits/stdc++. ...

  7. 数位dp总结

    由简单到稍微难点. 从网上搜了10到数位dp的题目,有几道还是很难想到的,前几道基本都是模板题,供入门用. 点开即可看题解. hdu3555 Bomb hdu3652 B-number hdu2089 ...

  8. 数位DP入门

    HDU 2089 不要62 DESC: 问l, r范围内的没有4和相邻62的数有多少个. #include <stdio.h> #include <string.h> #inc ...

  9. 数位DP之奥义

    恩是的没错数位DP的奥义就是一个简练的dfs模板 int dfs(int position, int condition, bool boundary) { ) return (condition ? ...

随机推荐

  1. Linux内存压力测试-memtester工具

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  2. quartz 数据库表含义解释

    http://blog.csdn.net/tengdazhang770960436/article/details/51019291 一.表信息解析: 1.1.qrtz_blob_triggers : ...

  3. JavaFX桌面应用开发-Button(按钮)与事件

    1:Button样式的操作原始代码: package application; import javafx.application.Application;import javafx.scene.Gr ...

  4. yagmail邮件模块

    昨天接到一个需求,就是要求用邮件发送一html文件.这里我想到了用yagmail #!/usr/bin/env python #-*- coding:utf-8 -*- import yagmail ...

  5. ModelBinder 请求容错性

    代码 //using System.Web.Mvc; public class TrimToDBCModelBinder : DefaultModelBinder { public override ...

  6. Laravel实用小功能

    Laravel实用小功能 1.控制访问次数 laravel5.2的新特性,通过中间件设置throttle根据IP控制访问次数 原理:通过回传三个响应头X-RateLimit-Limit,X-RateL ...

  7. PAT 1091. Acute Stroke (bfs)

    One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...

  8. Configuration must specify a spooling directory

    启动spooling源时报错: 原因:spooling配置文件有误 a1.sources.r1.type = spooldir a1.sources.r1.spooldir = /usr/local/ ...

  9. SSM(spring mvc+spring+mybatis)学习路径——2-2、spring MVC拦截器

    目录 2-2 Spring MVC拦截器 第一章 概述 第二章 Spring mvc拦截器的实现 2-1 拦截器的工作原理 2-2 拦截器的实现 2-3 拦截器的方法介绍 2-4 多个拦截器应用 2- ...

  10. Openfire:XMPP的几种消息类型

    XMPP 有以下几种消息类型: l   Normal l   Chat l   Groupchat l   Headline l   Error 根据官方文档(http://www.igniterea ...