hdu3555 Bomb(要49)
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?
The input terminates by end of file marker.
1
50
500
1
15
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#define inf 99999999
#define pi acos(-1.0)
#define maxn 1000050
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef long double ldb;
ll dp[65][12];
void init()
{
int i,j,k;
memset(dp,0,sizeof(dp));
for(j=0;j<=9;j++)dp[1][j]=1;
for(i=2;i<=64;i++){
for(j=0;j<=9;j++){
for(k=0;k<=9;k++){
if(j==4 && k==9 )continue;
dp[i][j]+=dp[i-1][k];
}
}
}
}
ll solve(ll x)
{
int wei[70],i,j,len=0;
ll t=x;
while(t){
wei[++len]=t%10;
t/=10;
}
wei[len+1]=0;
ll sum=0;
for(i=len;i>=1;i--){
for(j=0;j<wei[i];j++){
sum+=dp[i][j];
}
if(wei[i+1]==4 && wei[i]==9)break;
}
return sum;
}
int main()
{
int m,i,j,T;
ll n;
init();
scanf("%d",&T);
while(T--)
{
scanf("%lld",&n);
printf("%lld\n",n+1-solve(n+1));
}
return 0;
}
hdu3555 Bomb(要49)的更多相关文章
- [HDU3555]Bomb
[HDU3555]Bomb 试题描述 The counter-terrorists found a time bomb in the dust. But this time the terrorist ...
- HDU3555 Bomb[数位DP]
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- hdu3555 Bomb (记忆化搜索 数位DP)
http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Memory ...
- hdu---(3555)Bomb(数位dp(入门))
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- hdu 3555 Bomb(不要49,数位DP)
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- Bomb(要49)--数位dp
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- HDU3555 Bomb 数位DP第一题
The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...
- 【数位dp】hdu3555 Bomb
题意就是找0到n有多少个数中含有49.数据范围接近10^20 DP的状态是2维的dp[len][3]dp[len][0] 代表长度为len不含49的方案数dp[len][1] 代表长度为len不含49 ...
- [暑假集训--数位dp]hdu3555 Bomb
The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...
随机推荐
- LeetCode344 反转字符串
编写一个函数,其作用是将输入的字符串反转过来. 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man, a p ...
- Java基础概念性问题整理,面试题型整理,附带答案详解供参考,首次整理!
题目目录 Java基础 1.JDK1.8新特性? 2.面向对象和面向过程的区别? 3.什么是值传递和引用传递? 4.什么是不可变对象? 5.讲讲类的实例化顺序? 6.java 创建对象的几种方式 7. ...
- scp传文件夹
scp -r /root/backupdb/2014-08-15(文件夹) root@192.168.1.98:/root(目录)
- Java中的NIO进阶
目录 前言 NIO与多线程 Readable和Writeable的空触发 请求与返回的处理 事件的处理机制 NIO多线程使用的一个例子 前言 之前一篇文章简单介绍了NIO,并附了一个简单的例子,但是自 ...
- 使用bapi创建PO遇到问题(BAPI_PO_CREATE1
今天用 BAPI_PO_CREATE1创建po. 注意事项: vendor 供应商号:长度必须和系统一致,10位.如 2000025要写成 0002000025传递给参数. POITEM 中的 PO_ ...
- centos7+宝塔+ssrpanel v3 魔改版 前后端配置教程
一.服务端 1.安装宝塔 登录 SSH 后,直接安装宝塔. yum install -y wget && wget -O install.sh http://download.bt.c ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(89)-国际化,本地化,多语言应用
开篇 早年写过一篇多语言的应用 : 本地化(多语言) 讲述了如何创建多语言的资源文件,并利用资源文件来获得页面和请求的语言属性 本次补充这篇文章,的原因是在实际项目中,有多种需要多语言的情况 ...
- TCP客户端程序
TCP客户端程序的函数调用顺序为:socket -> connect -> send/recv socket.send和recv函数在TCP服务器程序中已经说过了,这里就不赘述了. con ...
- Spring框架入门浅析
一.Spring Bean的配置 在需要被Spring框架创建对象的实体类的类声明前面加注解:```@component```.这样在Spring扫描的时候,看到该注解就会在容器中创建该实体类的对象. ...
- 13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656
13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656