题意:  求高位往低位递减且  高位%低位==0(相邻) 数字数量

唯一要注意的就是前导零!!!!!!(正因为这个前导零   一开始的pre设置为0       )

比如  11  10 09 08 07 06 05 .。。。。说明要判断前导零

#include<bits/stdc++.h>
using namespace std;
//input by bxd
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i>=(b);--i)
#define RI(n) scanf("%d",&(n))
#define RII(n,m) scanf("%d%d",&n,&m)
#define RIII(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define RS(s) scanf("%s",s);
#define ll long long
#define REP(i,N) for(int i=0;i<(N);i++)
#define CLR(A,v) memset(A,v,sizeof A)
//////////////////////////////////
#define inf 0x3f3f3f3f
#define N 10+5
ll dp[N][];
ll a[N]; ll dfs(int pos,int pre, bool lead,bool limit )
{
if(!pos)return ; if(!limit&&!lead&&dp[pos][pre]!=-)return dp[pos][pre];
ll ans=;
int up=limit?a[pos]:;
rep(i,,up)
{
if(lead||pre>=i&&i&&pre%i==)
ans+=dfs(pos-,i, lead&&i==,limit&&i==a[pos]);
}
if(!limit&&!lead)dp[pos][pre]=ans;
return ans;
}
ll solve(ll x)
{
int pos=;
while(x)
{
a[++pos]=x%;
x/=;
}
return dfs(pos,,true,true);
}
int main()
{
int cas;
RI(cas);
CLR(dp,-);
while(cas--)
{
ll a,b;
cin>>a>>b;
printf("%lld\n",solve(b)-solve(a-));
}
return ;
}

beautiful number 数位dp的更多相关文章

  1. beautiful number 数位DP codeforces 55D

    题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...

  2. HDU 5179 beautiful number 数位dp

    题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5179 bc(中文): http://bestcoder.hdu.edu.cn/contes ...

  3. FZU2179/Codeforces 55D beautiful number 数位DP

    题目大意: 求  1(m)到n直接有多少个数字x满足 x可以整出这个数字的每一位上的数字 思路: 整除每一位.只需要整除每一位的lcm即可 但是数字太大,dp状态怎么表示呢 发现 1~9的LCM 是2 ...

  4. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

  5. 多校5 HDU5787 K-wolf Number 数位DP

    // 多校5 HDU5787 K-wolf Number 数位DP // dp[pos][a][b][c][d][f] 当前在pos,前四个数分别是a b c d // f 用作标记,当现在枚举的数小 ...

  6. codeforces 55D - Beautiful numbers(数位DP+离散化)

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  7. Codeforces Beta Round #51 D. Beautiful numbers 数位dp

    D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...

  8. CodeForces - 55D - Beautiful numbers(数位DP,离散化)

    链接: https://vjudge.net/problem/CodeForces-55D 题意: Volodya is an odd boy and his taste is strange as ...

  9. hdu 5898 odd-even number 数位DP

    传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...

随机推荐

  1. Solidity(address的四个方法)

    address的四个方法send,call,callcode,delegatecall 例子:发送以太币的send方法//下面是send方法,涉及到以太币的情况可能用到payable,senddemo ...

  2. 技术的热门度曲线:GHC

      全球最大的 IT 咨询公司高德纳(Gartner),有一个"技术热门度曲线"模型(Gartner Hype Cycle). 该模型认为,一门技术的发展要经历五个阶段. (1)启 ...

  3. Nginx(./configure --help)

    # ./configure --help --help print this message --prefix=PATH set installation prefix --sbin-path=PAT ...

  4. Oracle12c Release1 安装图解(详解)

    Oracle12c Release1 安装图解(详解) Oracle12c 终于发布了,代号为 c,即为 Cloud(云),替代了网格 (Grid)运算. 我的机器基础环境:Windows8(x64) ...

  5. Confluence 6 数据中心的缓存

    在 Confluence 数据中心(集群)你需要分布缓存和每一个节点的缓存.在集群管理界面,将会定义分布缓存和节点本地缓存. 缓存配置文件存储在集群共享目录中的 home 目录下面. https:// ...

  6. hdu5758 思维,树形dp

    /*可以推测从叶子结点传送到叶子节点才能使传送次数最少,如果是偶数个叶子结点,那么传送leaf/2次就是答案,如果是奇数个叶子结点,则还有单独一条链需要覆盖dp[u]表示覆盖完u为根的子树需要走的边数 ...

  7. javaScript中的querySelector()与querySelectorAll()的区别

    之前,在JavaScript获取文档元素一文中,我曾介绍了获取文档元素的几种方法,最后一种方法是通过选择器获取文档元素.它的核心思想便是利用querySelector()或querySelectorA ...

  8. 网站申请HTTPS 访问

    #生成证书和key openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /opt/nginx/pdk.key -out /opt ...

  9. 阻止Java反编译蛋疼方法

    public class landv { private static String companyName="landv测试"; public static void main( ...

  10. Html 文字排版

    文字竖立排版,方法一 @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="v ...