//反向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. MongoDB 倾向于将数据都放在一个 Collection 下吗?

    不是这样的. Collection 的单个 doc 有大小上限,现在是 16MB,这就使得你不可能把所有东西都揉到一个 collection 里.而且如果 collection 结构过于复杂,既会影响 ...

  2. [HTML & CSS] HTML和CSS基础知识

    最近将博客简单地修饰了下,需要用到HTML和CSS代码,花了一天时间学习了一下这两方面的知识.虽然内容很简单,但是足够用来修改自己的博客了. 1. HTML 1.1. HTML介绍 HTML与CSS的 ...

  3. servlet理论学习

    servlet是和凭条无关的服务器端的组件,它运行在servlet容器中,servlet容器负责servlet和客户的通信以及调用servlet方法.servlet和客户的通信是采用“请求和响应的模式 ...

  4. PHP截取中英文混合字符

    <?php //////////////////////////////////////////////////////////////////// // PHP截取中英文及标点符号混合的字符串 ...

  5. 脚踏实地学C#3-装箱和拆箱

    装箱:一种接受值类型的值,根据这个值在堆中创建一个完整的引用类型对象并返回对象的引用(堆地址)的隐式转换 int i_number = 2; //在栈中声明int类型i_Number变量并初始化 ob ...

  6. mysql 数据库电脑间迁移

    应用实例: database1(简称DB1)保存在PC1中的MySQL中,需要将DB1迁移到PC2中的MySQL中 环境: win7 MySQL5.7.13 参考: http://stackoverf ...

  7. python print 字体颜色

    例子: print '\033[35;43m(1)ip转换成数字\033[0m' \033[35;43m    ===>35列属于字颜色,43列属于背景颜色 字背景颜色范围: 40--49  4 ...

  8. AJAX获取数据,需要添加事件

    如果是通过异步请求从后端获取的数据来渲染页面,要添加事件,必须要在页面已有的元素上,添加时间代理.因为页面渲染需要时间,如果直接绑定在响应时间元素上面,很有可能触发不了事件.

  9. python学习笔记——Thread常用方法

    Thread对象中的一些方法: 以前说过多线程,用到threading模块中的Thread对象,其中的start和run方法比较熟悉了,start()是重载了Thread对象中的run方法,其实作用还 ...

  10. 华为codecraft2018总结

    华为codecraft2018总结 想来也是参加了第二次了,自己还是那么的菜.总结下今年的比赛,得奖是不存在的了,但是收获还是有的. 代码相关的都在这里了:https://github.com/hui ...