难受啊!!越做题是越感觉菜,这个又被几个坑给卡住了(只有我这个学渣才会卡)

坑点: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的更多相关文章

  1. hdu3555 Bomb (记忆化搜索 数位DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  2. hdu---(3555)Bomb(数位dp(入门))

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submi ...

  3. HDU 3555 Bomb 数位dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...

  4. HDU 3555 Bomb(数位DP)

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Subm ...

  5. Bomb HDU - 3555 (数位DP)

    Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...

  6. [暑假集训--数位dp]hdu3555 Bomb

    The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...

  7. HDU3555 Bomb —— 数位DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others)    M ...

  8. HDU 3555 Bomb(数位DP模板啊两种形式)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found ...

  9. hud 3555 Bomb 数位dp

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Subm ...

  10. Hdu Bomb(数位DP)

    Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submiss ...

随机推荐

  1. 第十七节,OpenCV(学习六)图像轮廓检测

    1.检测轮廓 轮廓检测是图像处理中经常用到的,OpenCV-Python接口中使用cv2.findContours()函数查找检测物体的轮廓. cv2.findContours(image, mode ...

  2. PHP 【六】

    命名空间 教学网站的内容不知道再怎么“笔记化”,用之即可 面向对象 类定义 创建对象  $xxx = new 类名: 调用成员方法  $xxx->方法名(参数): 举例: <?php cl ...

  3. 封装selenium自动化框架中的截图功能

    对selenium自带的截图功能进行封装: 以下为封装的代码,自定义一个.py文件即可,图片路径自己设置一个. #coding:utf-8 class Screen(object): ''' 封装的截 ...

  4. 网络流板子/费用流板子 2018南京I题+2016青岛G题

    2018南京I题: dinic,链式前向星,数组队列,当前弧优化,不memset全部数组,抛弃满流点,bfs只找一条增广路,每次多路增广 #include <bits/stdc++.h> ...

  5. 【算法】Normalization

    Normalization(归一化) 写这一篇的原因是以前只知道一个Batch Normalization,自以为懂了.结果最近看文章,又发现一个Layer Normalization,一下就懵逼了. ...

  6. css属性position: static|relative|absolute|fixed|sticky简单解析

    目录 static 静态定位(默认) relative 相对定位 正常文档流 加了relative之后的布局 加上margin/padding/border之后的布局 absolute 绝对定位 正常 ...

  7. 使用IIS应用程序初始化来保持ASP.NET应用程序的活动

    https://weblog.west-wind.com/posts/2013/Oct/02/Use-IIS-Application-Initialization-for-keeping-ASPNET ...

  8. JS中5种经典继承方式

    继承 JS中继承的概念: 通过[某种方式]让一个对象可以访问到另一个对象中的属性和方法,我们把这种方式称之为继承 并不是所谓的xxx extends yyy 为什么要使用继承? 有些对象会有方法(动作 ...

  9. xiao_ren

  10. Python制作微信小助手

    网址: https://mp.weixin.qq.com/s/uWSgeD5FyzXV3LsMNus01Q