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 ...
随机推荐
- 【Redis3.0.x】实战案例
Redis3.0.x 实战案例 简介 <Redis实战>的学习笔记和总结. 书籍链接 初识 Redis Redis 简介 Redis 是一个速度非常快的键值对存储数据库,它可以存储键和五种 ...
- GCC 概述:C 语言编译过程详解
Tags: C Description: 关于 GCC 的个人笔记 GCC 概述 对于 GCC 6.1 以及之后的版本,默认使用的 C++ 标准是 C++ 14:使用 -std=c++11 来指定使用 ...
- 容器编排系统K8s之Prometheus监控系统+Grafana部署
前文我们聊到了k8s的apiservice资源结合自定义apiserver扩展原生apiserver功能的相关话题,回顾请参考:https://www.cnblogs.com/qiuhom-1874/ ...
- 【ORA】ORA-27101快速处理方法
今天朋友的数据库出了问题,报错如下: 这个问题主要是是spfile和pfile文件不一致导致的, 生成一个pfile,完了用pfile启动数据库即可 SQL> create pfile '/ho ...
- merge join pg伪代码
Join { get initial outer and inner tuples INITIALIZE do forever { while (outer != inner) { SKIP_TEST ...
- [Usaco2010 Hol]cowpol 奶牛政坛
题目描述: 农夫约翰的奶牛住在N (2 <= N <= 200,000)片不同的草地上,标号为1到N.恰好有N-1条单位长度的双向道路,用各种各样的方法连接这些草地.而且从每片草地出发都可 ...
- C#从入门到放弃治疗一:初探C#世界
C#是一款高级的面向对象语言,运行于.NET framework之上的高级程序设计语言.其语言规范和,语法和java有着惊人的类似之处.所以如果你在学习C#之前有着java的基础,你将快速地入门.当然 ...
- Sentry(v20.12.1) K8S 云原生架构探索,JavaScript Enriching Events(丰富事件信息)
系列 Sentry-Go SDK 中文实践指南 一起来刷 Sentry For Go 官方文档之 Enriching Events Snuba:Sentry 新的搜索基础设施(基于 ClickHous ...
- .NetCore 在不同位置添加过滤器
前言 以ParaModelValidateAttribute(参数校验)和ErrorCatch(错误捕捉)为例. 在方法上添加(局部) 这种方式比较灵活 [ParaModelValidate] [Er ...
- JVM(五)手动解析.class文件
一:不同进制之间的转换 二进制:逢2进1,数字0-1. 八进制:逢8进1,数字0-7.三位二进制表示一位八进制.三位二进制最大为111,最大为7. 十进制:逢10进1,数字0-9.四位二进制表示一位十 ...