题意:  求高位往低位递减且  高位%低位==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. Less常用知识点

    上篇文章介绍了如何安装Less,我们将所有东西都写在.less里面,最后通过命令将.less转换成.css文件,就可以放入到项目里用了.今天了解一些less常用知识点. 1.变量:声明两个变量,一个是 ...

  2. j2cache笔记

    初步理解 eg: https://my.oschina.net/javayou https://my.oschina.net/tinyframework/blog/538363?p=2 https:/ ...

  3. est是基于less的样式工具库

    网址:http://ecomfe.github.io/est/ 此处HTML中如果直接引用less就会报错! est 如果直接引用less和js 是会报错的 样式规范:https://www.zybu ...

  4. Oracle 行转列pivot 、列转行unpivot 的Sql语句总结

    这个比较简单,用||或concat函数可以实现 select concat(id,username) str from app_user select id||username str from ap ...

  5. 高性能MySQL(第3版) 中文PDF带目录清晰版

    下载地址: <高性能MySQL(第3版)>编辑推荐:"只要你不敢以MySQL专家自诩,又岂敢错过这本神书?""一言以蔽之,写得好,编排得好,需要参考时容易到爆 ...

  6. Confluence 6 属性的一个示例

    下面是有关 Confluence 页面被调用的前几行的访问概述. [344ms] - /display/ds/Confluence+Overview [313ms] - SiteMesh: parse ...

  7. Fatal error: Uncaught Error: Call to undefined function mysqli_connect()

    sudo apt-get install php7.2-mysql  //版本号肯能不一样 sudo dpkg-reconfigure  php7.2-mysql sudo /etc/init.d/m ...

  8. PDF怎么去除页眉页脚,PDF页眉页脚编辑方法

    我们在使用文件的时候需要编辑页眉页脚的时候,这个时候我们应该怎么做呢,相信别的文件大家都知道怎么编辑了,PDF文件大家都知道吗,最开始接触这个文件的时候小编觉得很难,之后找到技巧之后也并没有很难,今天 ...

  9. bzoj 1495

    这是一道...卡了我一个月的树形dp... 我真是太弱了... 其实仔细想想,这题的核心思路并不是特别复杂,但是的确存在不小的难度 作为一个看过全网基本所有题解+标程才弄明白这题到底怎么回事的蒟蒻,我 ...

  10. mysql入门练习

    2.详细解释列mysql执行语句的每个参数与参数值的含义 ​ mysql -hlocalhost -P3306 -uroot -proot 连接数据库,端口号为3306, 用户名root, 密码roo ...