D - Bomb
//反向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的更多相关文章
- HDU3555 Bomb[数位DP]
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- Leetcode: Bomb Enemy
Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return ...
- HDU 5934 Bomb(炸弹)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 3622 Bomb Game(二分+2-SAT)
Bomb Game Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- Bomb
Description The counter-terrorists found a time bomb in the dust. But this time the terrorists impro ...
- CF 363B One Bomb(枚举)
题目链接: 传送门 One Bomb time limit per test:1 second memory limit per test:256 megabytes Description ...
- hdu3555 Bomb (记忆化搜索 数位DP)
http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Memory ...
- [HDU3555]Bomb
[HDU3555]Bomb 试题描述 The counter-terrorists found a time bomb in the dust. But this time the terrorist ...
- hdu 5934 Bomb
Bomb Problem Description There are N bombs needing exploding.Each bomb has three attributes: explodi ...
- HDOJ 3555 Bomb
数位DP的DFS写法.... Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Oth ...
随机推荐
- 把tomcat写到Windows系统服务器的服务中
首先准备一个免安装的tomcat服务器,和一个Windows系统. 在“C:\Windows\SysWOW64”中找到cmd.exe的执行文件,以管理员身份启动: 进入到tomcat的bin文件夹, ...
- 【甘道夫】Eclipse+Maven搭建HBase开发环境及HBaseDAO代码演示样例
环境: Win764bit Eclipse Version: Kepler Service Release 1 java version "1.7.0_40" 第一步:Eclips ...
- 学习selendroid初衷
为了解决工作中的一个问题,开始学习selendroid. 工作中,有一些所谓H5应用需要测试,这些应用程序描述如下: 通过微信平台传播,也就是依靠微信的朋友圈传播: 可以通过类似于http://XXX ...
- hihocoder #1094 : Lost in the City微软苏州校招笔试 12月27日 (建图不大【暴力枚举】 子图的4种形态 1Y )
#1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...
- 自动化测试框架selenium+java+TestNG——TestNG详解
TestNG按顺序执行case package com.testngDemo; import org.testng.annotations.AfterClass; import org.testng. ...
- Nginx配置故障转移
当上游服务器(真实访问服务器),一旦出现故障或者是没有及时相应的话,应该直接轮训到下一台服务器,保证服务器的高可用. 如果上游服务器的某一台宕机了,直接轮训到下一个~ 8080 8081 8082 关 ...
- codeforces 665C C. Simple Strings(乱搞)
题目链接: C. Simple Strings time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- poj1639顶点度限制生成树
题目:http://poj.org/problem?id=1639 对根的度数有限制的最小生成树: 先忽略根,跑最小生成树,得到几个连通块,再一一与根连上: 然后在限制内用根连出去的边来使生成树更小, ...
- vuex本地存储
vuex与localstorage 区别:vuex数据存储的内存,localstorage的数据存储在本地 应用场景:vuex用于组件之间的传值,localstorage用于不同页面之间的传值 永久性 ...
- themeforest 免费模板
http://www.im286.com/thread-9550365-1-1.html 官网:http://themeforest.net/item/elena-responsive-email-t ...