hdu3555Bomb(数位dp)
Bomb
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 18659 Accepted Submission(s):
6891
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?
<= 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.
final points of the power.
1
50
500
1
15
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.
#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)的更多相关文章
- 数位dp真·浅谈 By cellur925
预警:由于是从$Vergil$学长那里和$Mathison$大神那里学来的,所以清一色记忆化搜索!qwq 巨佬的数位dp讲解(未来的咕咕日报头条): https://www.luogu.org/blo ...
- 【BZOJ1662】[Usaco2006 Nov]Round Numbers 圆环数 数位DP
[BZOJ1662][Usaco2006 Nov]Round Numbers 圆环数 Description 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...
- bzoj1026数位dp
基础的数位dp 但是ce了一发,(abs难道不是cmath里的吗?改成bits/stdc++.h就过了) #include <bits/stdc++.h> using namespace ...
- uva12063数位dp
辣鸡军训毁我青春!!! 因为在军训,导致很长时间都只能看书yy题目,而不能溜到机房鏼题 于是在猫大的帮助下我发现这道习题是数位dp 然后想起之前讲dp的时候一直在补作业所以没怎么写,然后就试了试 果然 ...
- HDU2089 不要62[数位DP]
不要62 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 数位DP GYM 100827 E Hill Number
题目链接 题意:判断小于n的数字中,数位从高到低成上升再下降的趋势的数字的个数 分析:简单的数位DP,保存前一位的数字,注意临界点的处理,都是套路. #include <bits/stdc++. ...
- 数位dp总结
由简单到稍微难点. 从网上搜了10到数位dp的题目,有几道还是很难想到的,前几道基本都是模板题,供入门用. 点开即可看题解. hdu3555 Bomb hdu3652 B-number hdu2089 ...
- 数位DP入门
HDU 2089 不要62 DESC: 问l, r范围内的没有4和相邻62的数有多少个. #include <stdio.h> #include <string.h> #inc ...
- 数位DP之奥义
恩是的没错数位DP的奥义就是一个简练的dfs模板 int dfs(int position, int condition, bool boundary) { ) return (condition ? ...
随机推荐
- (转)Struts2的拦截器
http://blog.csdn.net/yerenyuan_pku/article/details/68648101 Struts2的拦截器 拦截器的概述 拦截器,在AOP(Aspect-Orien ...
- Cesium学习笔记(四)Camera ----http://blog.csdn.net/hobhunter/article/details/74909641
Cesium 相机控制场景中的视野.操作相机的方法有很多,如旋转,缩放,平移和飞到目的地.Cesium具有默认的鼠标和触摸事件处理程序与相机进行交互,还有一个API以编程方式操纵相机. 我们可以使用该 ...
- zabbix_agent自动发现服务端口
应用背景: zabbix监控系统介绍及安装,参考大牛运维生存时间,在这儿就不啰嗦了 为了zabbix-agent端能自动把服务器端的服务端口汇报给 zabbix server端,监控其端口 ...
- 在Python中利用CVXOPT求解二次规划问题
工作中需要用到cvxopt,cvxopt安装有坑,大家注意下.1.首先一定要卸载numpy,无论是直接安装的,还是anaconda安装的,主要是必须用whl安装numpy才不会有包的冲突2.二次规划包 ...
- Linux的安装教程
CentOS 6 + VMWare: 资源:https://pan.baidu.com/s/1AA4gaMpaoVaMor-tRU-n7A 提取码:6e8r ( 内附 VMWare 14 激活 ...
- python 函数编写指南
#函数编写指南:1.给函数指定描述性名称,且只在其中是用小写字母和下划线 2.每个函数都应包含简要的阐述其功能的注释,该注释应紧跟在函数定义后面,且采用文档字符串格式 3.给形参指定默认值时,等号两边 ...
- protel99se 问题汇总(不定期更新)
1.在PROTEL99SE中,怎样改变敷铜的线宽? 规则---manufacturing----polygon connect style 里面设置:或Power polygon connect st ...
- vue组件 $children,$refs,$parent的使用详解
1)$refs 首先你的给子组件做标记.demo :<firstchild ref="one"></firstchild> 然后在父组件中,通过this.$ ...
- 【codeforces 510C】Fox And Names
[题目链接]:http://codeforces.com/contest/510/problem/C [题意] 给你n个字符串; 问你要怎么修改字典序; (即原本是a,b,c..z现在你可以修改每个字 ...
- python中添加日志记录到文件
1.实现python日志功能 2.只输出到文件,不输出到控制台 #encoding:utf-8 import logging from common import path_util logging_ ...