数位dp-Bomb
难受啊!!越做题是越感觉菜,这个又被几个坑给卡住了(只有我这个学渣才会卡)
坑点:1.考虑n是否已包含49,有的话还要再+1.
2, 注意从最高开始考虑时,再判断时要考虑它本身为0的情况,.比如n=5701,在考虑最高位时,其实是在考虑0~5000所能组成的含49的数的个数,这个是包含f[i][2]中的前导0并且千位最高位也可为0
#include<bits/stdc++.h>
using namespace std;
//#define LL long long
typedef __int64 LL;
LL f[][];
int n[];
void init()
{
// f[1][9]=1;
// f[1][0]=10;
memset(f,,sizeof(f));
f[][]=;
for(int i=; i<=; i++)
{
f[i][]=f[i-][]*+f[i-][];
f[i][]=f[i-][];
f[i][]=f[i-][]*-f[i-][];
}
}
int main()
{
int t;
scanf("%d",&t);
init();
// for(int i=1;i<=20;i++)
// printf("%lld\n",f[i][1]+f[i][0]);
while(t--)
{
// string s;
// cin>>s;
// for(int i=0; i<s.size(); i++)
// n[s.size()-i]=s[i]-'0';
LL a;
scanf("%I64d",&a);
int len=;
LL ans=;
int flag=;
a++;
while(a)
{
n[++len]=a%;
a/=;
}
n[len+]=;
for(int i=len; i>=; i--)
{
ans+=n[i]*f[i-][];
if(flag)
ans+=n[i]*f[i-][];
else if(n[i]>)
ans+=f[i-][];
if(n[i+]==&&n[i]==)
flag=;
}
printf("%I64d\n",ans);
}
return ;
}
数位dp-Bomb的更多相关文章
- 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 数位dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...
- HDU 3555 Bomb(数位DP)
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Subm ...
- Bomb HDU - 3555 (数位DP)
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...
- [暑假集训--数位dp]hdu3555 Bomb
The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...
- HDU3555 Bomb —— 数位DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) M ...
- HDU 3555 Bomb(数位DP模板啊两种形式)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found ...
- hud 3555 Bomb 数位dp
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Subm ...
- Hdu Bomb(数位DP)
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submiss ...
随机推荐
- ruban后台项目启动。进入断点
eclipse debug启动 进入断点显示-------------HikariPool-1 - Starting... 原因是 eclipse和tomcat的交互而产生的,在以debug模式启动t ...
- Spring框架-IOC和AOP简单总结
参考博客: https://blog.csdn.net/qq_22583741/article/details/79589910 1.Spring框架是什么,为什么,怎么用 1.1 Spring框架是 ...
- css3写出飘雪花特效
大冬天的,飘雪花的特效,你可能要用上了吧.通常情况下用jQuery写飘雪花的特效,但用css3写,其实特别简单,新手一看就懂,那就告别jQuery,用css3轻松搞定飘雪花特效吧! 点击查看特效演示 ...
- 医学图像数据(一)——TCIA基本介绍
1.介绍 The Cancer Imaging Archive (TCIA)是癌症研究的医学图像的开放获取数据库.该网站由国家癌症研究所(NCI)癌症影像计划资助,合同由阿肯色大学医学科学院管理.存档 ...
- Saltstack自动化操作记录(1)-环境部署【转】
早期运维工作中用过稍微复杂的Puppet,下面介绍下更为简单实用的Saltstack自动化运维的使用. Saltstack知多少Saltstack是一种全新的基础设施管理方式,是一个服务器基础架构集中 ...
- 删除Win10资源管理器中的3D对象/音乐/视频文件夹
Win10如何删除资源管理器中的3D对象/音乐/视频等文件夹?使用Win10系统的用户都知道,打开此电脑之后,资源管理上面会显示文档/音乐/视频等7个文件夹,一些用户认为很少使用到它们,想要除之而后快 ...
- 019_UT、IT、ST、UAT
软件开发中的完成测试环境所包括的环节包括:UT.IT.ST.UAT UT = Unit Test 单元测试 IT = System Integration Test 集成测试 ST = System ...
- 自定义QGraphicsItem
简述: QGraphicsItem 是场景中 item 的基类.图形视图提供了一些典型形状的标准 item,例如:矩形 ( QGraphicsRectItem ).椭圆 ( QGraphicsElli ...
- MySQL 的安装与使用(一)
一.Windows 上安装 MySQL 1.Windows 上安装 MySQL 相对来说会较为简单,地那就链接 https://cdn.mysql.com//Downloads/MySQL-8.0/m ...
- bat实现固定时间循环抓取设备log
背景:测试时需要实时抓取android设备log,但是一份log抓取过来非常庞大(有时超过500M+,编辑器都打不开,还得找工具进行分割,甚是蛋疼),查看也非常不方便. 解决:基于上述情况,与其之后进 ...