//反向62
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std; typedef long long ll;
// const int maxn = 1e5+5;
ll n;
ll a[];
ll dp[][]; //下标,前面是否4,是否有前导0, 是否有限制
ll dfs(ll pos, ll sta, ll pre, ll limit){
if(pos == -) return ;
if(!limit && dp[pos][sta] != -)
return dp[pos][sta];
int up = limit?a[pos]:;
ll ans = ;
for(int i = ;i <= up;i++){
if(pre == && i == ){
continue;
}
ans += dfs(pos-, i == , i, limit && i == a[pos]);
}
if(!limit) dp[pos][sta] = ans;
return ans;
} ll solve(ll x){
ll pos = ;
while(x){
a[pos++] = x%;
x /= ;
}
return dfs(pos-, , -, true);
} int main(){
memset(dp, -, sizeof dp);
int t;
scanf("%d", &t);
while(t--){
scanf("%lld", &n);
ll ans = solve(n);
printf("%lld\n", n - ans + );
}
return ;
}

D - Bomb的更多相关文章

  1. HDU3555 Bomb[数位DP]

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

  2. Leetcode: Bomb Enemy

    Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return ...

  3. HDU 5934 Bomb(炸弹)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  4. hdu 3622 Bomb Game(二分+2-SAT)

    Bomb Game Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. Bomb

    Description The counter-terrorists found a time bomb in the dust. But this time the terrorists impro ...

  6. CF 363B One Bomb(枚举)

    题目链接: 传送门 One Bomb time limit per test:1 second     memory limit per test:256 megabytes Description ...

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

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

  8. [HDU3555]Bomb

    [HDU3555]Bomb 试题描述 The counter-terrorists found a time bomb in the dust. But this time the terrorist ...

  9. hdu 5934 Bomb

    Bomb Problem Description There are N bombs needing exploding.Each bomb has three attributes: explodi ...

  10. HDOJ 3555 Bomb

    数位DP的DFS写法.... Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Oth ...

随机推荐

  1. tornado之模板扩展

    当我们有多个模板的时候,很多模板之间其实相似度很高.我们期望可以重用部分网页代码.这在tornado中可以通过extends语句来实现.为了扩展一个已经存在的模板,你只需要在新的模板文件的顶部放上一句 ...

  2. hdu1427 速算24点

    </pre><pre> //#pragma comment(linker, "/STACK:102400000,102400000") //HEAD #in ...

  3. machine learning for hacker记录(4) 智能邮箱(排序学习&推荐系统)

    本章是上一章邮件过滤技术的延伸,上一章的内容主要是过滤掉垃圾邮件,而这里要讲的是对那些正常的邮件是否可以加入个性化元素,由于每个用户关心的主题并非一样(有人喜欢技术类型的邮件或者购物促销方便的内容邮件 ...

  4. Raspberry Pi3 ~ C语言控制串口

    注明出处:http://www.cnblogs.com/einstein-2014731/p/5551846.html 使用C语言控制树莓派3B的串口,实现使用串口收发数据的目的.之前以为这个串口是被 ...

  5. SVN版本控制中.a无法提交问题

    1.首先xcode是默认忽略.a文件的.改变方法如下: 1⃣️. 打开终端,  在命令行中输入: vi ~/.subversion/config  来打开配置文件.2⃣️. 然后, 在[miscell ...

  6. 使用IIS建立主机到虚拟机的端口转发

    主机是笔记本电脑,通过一个TPLINK智能扩展卡,作为服务器供给手机APP当作服务器. 但真正的Web服务,在主机的VMWare Workstation虚拟机80端口. 那么主机和手机形成的网络为19 ...

  7. Yii的缓存机制之页面缓存

    页面缓存是不能通过片段缓存来实现的,因为布局和内容不能同时缓存.只能通过过滤器来生成缓存. 实现方法: 在控制器里使用过滤器来实现 function filters (){ return array( ...

  8. 关于使用response.addHeader下载中文名乱码问题

    介绍下我项目中遇到的问题:在数据库导出Excel文件的过程中,导出文件中文名始终异常,最终结果发现需要在response.addHeader 中的 filename = "xxxx" ...

  9. codevs 1147 排座椅

    传送门 题目描述 上课的时候总会有一些同学和前后左右的人交头接耳,这是令小学班主任十分头疼的一件事情.不过,班主任小雪发现了一些有趣的现象,当同学们的座次确定下来之后,只有有限的D对同学上课时会交头接 ...

  10. 解决最近windows版本Node.js中npm出现的“Error: ENOENT, stat 'C:\Users\UserName\AppData\Roaming\npm”的问题

    (转载请注明出处,from www.cnblogs.com/xdxer) 问题可能如下所示 解决方案: 在 'C:\Users\UserName\AppData\Roaming\‘ 下手动的增加一个文 ...