//反向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. appium()-java-client-api

    //appium java-client-api 介绍 原文地址:http://appium.github.io/java-client/index-all.html#_S_ A B C D E F  ...

  2. chatty: uid=10549(u0_a549) com.exampleidentical 40 lines

    主要是因为你的app在短时间内输出太多次的日志,导致日志丢失 As soon as app considered 'chatty' by logcat (more than 5 lines per s ...

  3. java反射技术实例

    java反射技术实例​1. [代码][Java]代码     package com.gufengxiachen.java.reflectiontest; public class Person {p ...

  4. cnn handwrite使用原生的TensorFlow进行预测

    100个汉字,放在data目录下.直接将下述文件和data存在同一个目录下运行即可. 关键参数: run_mode = "train" 训练模型用,修改为validation 表示 ...

  5. yii表单的各种验证

    /验证规则详细配置 public function rules() { // NOTE: you should only define rules for those attributes that ...

  6. 七号信令中TUP协议的主要消息和故障问题

      CIC码说明: TUP消息的路由标记: 为OPC 24位 DPC24位 CIC 12位,12位CIC 的低5为时隙号,其中后4位为SLC,高7位为系统号.     CIC配置需要注意几个问题:   ...

  7. SDOI2017 Round1 Day2 题解

    T2好厉害啊……AK不了啦……不过要是SCOI考这套题就好了240保底. BZOJ4819 新生舞会 模板题,分数规划+二分图最大权匹配. 费用流跑得过,可以不用KM. UPD:分数规划用迭代跑得飞快 ...

  8. 洛谷P1073最优贸易——双向取值

    题目:https://www.luogu.org/problemnew/show/P1073 由于任何城市都可以多次经过,所以可以随便走,也就不用太在意有向边和无向边,把无向边当做两条有向边处理: 根 ...

  9. Ubuntu16.04 + cuda9.0 + cudnn7.1.4 + tensorflow安装

    安装前的准备 UEFI 启动GPT分区 Win10和Ubuntu16.04双系统安装 ubuntu16.04 NVIDIA 驱动安装 ubuntu16.04 NVIDIA CUDA8.0 以及cuDN ...

  10. Code-NFine:.NET快速开发平台 NFine.Framework Web框架

    ylbtech-Code-NFine:.NET快速开发平台 NFine.Framework Web框架 1.NFine.Framework 详细介绍返回顶部 1. NFine 是基于 C# 语言的极速 ...