Bomb HDU - 3555
Bomb HDU - 3555
求1~n中含有49数的个数
#include<bits/stdc++.h> #define LL long long
using namespace std; LL T,x,dp[][],shu[]; LL dfs(LL pos,LL x,bool ok,bool limit){
if(!pos) return ok;
if(!limit&&dp[pos][x]) return dp[pos][x];
LL cnt=,up=limit?shu[pos]:;
for(LL i=;i<=up;i++)
{
bool flg=false;
if(x==&&i==) flg=true;
if(ok) flg=true;
cnt+=dfs(pos-,i,flg,limit&&shu[pos]==i);
}
if(!limit) dp[pos][x]=cnt;
return cnt;
} LL slove(LL x){
LL k=;
while(x){
shu[++k]=x%;
x/=;
}
return dfs(k,,,true);
} int main()
{
scanf("%lld",&T);
while(T--){
scanf("%lld",&x);
printf("%lld",slove(x));
if(T) puts("");
}
return ;
}
Bomb HDU - 3555的更多相关文章
- Bomb HDU - 3555 (数位DP)
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...
- Bomb HDU 3555 dp状态转移
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意: 给出一个正整数N,求出1~N中含有数字“49”的数的个数 思路: 采用数位dp的状态转移方程 ...
- 数位DP入门(A - 不要62 HDU - 2089 &&B - Bomb HDU - 3555 )
题目链接:https://cn.vjudge.net/contest/278036#problem/A 具体思路:对于给定的数,我们按照位数进行运算,枚举每一位上可能的数,在枚举的时候需要注意几个条件 ...
- Bomb HDU - 3555 数位dp
Code: #include<cstdio> #include<algorithm> #include<cstring> #include<string> ...
- 数位DP入门之hdu 3555 Bomb
hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区 ...
- 递推、数位DP解析(以HDU 2089 和 HDU 3555 为例)
HDU 2089 不要62 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2089 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人 ...
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- HDU 3555 Bomb 数位dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...
- (数位dp)Bomb (hdu 3555)
http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found ...
随机推荐
- CoffeeScript里的or
CoffeeScript里的or,其实会被编译为 || 这并没有什么令人惊奇之处.我惊讶的是类似这样一个表达式: word = null hi = word or "Hello World! ...
- springmvc20170322
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...
- java Map 转 List
public static void testMapVoid () { Map map = new HashMap(); map.put("a", "a1"); ...
- luogu 3383【模板】线性筛素数
我太菜了 %韩神 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib&g ...
- 【POJ 2965】 The Pilots Brothers' refrigerator
[题目链接] http://poj.org/problem?id=2965 [算法] 位运算 [代码] #include <algorithm> #include <bitset&g ...
- 第二周 Leetcode 493. Reverse Pairs(HARD)
leetcode 493跟经典的逆序对问题没有什么区别, 首先考虑对数组前半部和后半部求逆序对数,若能保证两段数组都有序,则显然可以在线性时间内求出对数. 所以我们采用归并排序的方法,一方面让数组有序 ...
- Makefile 实际用例分析(一) ------- 比较通用的一种架构
这里不再说Makefile的基本知识,如果需要学习,那么请参考: 下载:makefile 中文手册 或者 点击打开链接 或者 跟我一起写Makefile( 陈皓 ) 这里说的是一般的实际的一个工程应该 ...
- 03_jni_helloworld_完成
通过ndk-build编译C的代码.cd /d就是直接进到我的目录里面. 打开ANDROID-MK.HTML Introduction: This document describes the syn ...
- Text段、Data段和BSS段
不同的compiler在编译的过程中对于存储的分配可能略有不同,但基本结构大致相同. 大体上可分为三段:Text段.Data段和BSS段. text段用于存放代码,通常情况下在内存中被映射为只读,但d ...
- thinkphp调试手段
使用ThinkPHP应该掌握的调试手段经常看到有人问到findAll的返回数据类型是什么之类的问题,以及出错了不知道什么原因的情况,其实还是没有熟悉ThinkPHP内置的调试手段和方法,抛开IDE本身 ...