CodeForces55D

CodeForces 55D-Beautiful numbers【数位DP+思维】 题目链接:https://codeforces.com/problemset/problem/55/D 题意: Volodya 是一个古怪的男孩,他的品味与众不同。对他来说,一个正整数是漂亮数,当且仅当它能够被自身的各非零数字整除。我们不必与之争辩,只需计算给定范围中有多少个漂亮数。 输入 输入的第一行包含了测试用例的数目t(1 ≤ t ≤ 10)。接下来的t行,每行包含两个自... 阅读详情

Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.

Input
The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two natural numbers li and ri (1 ≤ li ≤ ri ≤ 9 ·1018).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Output
Output should contain t numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from li to ri, inclusively).

Example
Input
1
1 9
Output
9
Input
1
12 15
Output
2

用每个数除以数位的LCM
但是会发现每个数%2520就可以存状态了
2520是1到9的LCM

坑点 0算一个

#include<iostream>
#include<cmath>
#include<queue>
#include<stack>
#include<memory.h>
#include<algorithm>
using namespace std;
long long shi[21];
long long dp[21][7000][100];
long long mp[9000000];
int gcd(int a, int b)
{
    if (b == 0) return a;
    return gcd(b, a%b);
}
long long lcm(long long q, long long w)
{
    return q*w / gcd(q, w);
}
long long bte[30];
long long qw = 0;
long long dfs(long long weishu, long long biaoji, long long benshen, long long quanti)
{
    if (!mp[quanti])mp[quanti] = ++qw;
    if (weishu == 0)
    {
    //  if (qiandao == 0)return 0;
        if (benshen%quanti)return 0;
        return 1;
    }
    if (biaoji&&dp[weishu][benshen][mp[quanti]] != -1)return dp[weishu][benshen][mp[quanti]];
    long long da = 0;
    long long bianjie = biaoji ? 9 : bte[weishu];
    for (int a = 0;a <= bianjie;a++)
    {
        int xyb = benshen * 10 + a;
        xyb %= 2520;
        int xyq = quanti;
        if (a)xyq = lcm(quanti, a);
        da += dfs(weishu - 1, biaoji || a < bianjie,xyb, xyq);
    }
    if (biaoji)dp[weishu][benshen][mp[quanti]] = da;
    return da;
}
long long jiejue(long long q)
{
    if (q == 0)return 1;
    if (q < 0)return 0;
    //if (q < 10)return q;
    long long y = q;
    bte[0] = 0;
    while (y)
    {
        bte[++bte[0]] = y % 10;
        y /= 10;
    }
    return dfs(bte[0], 0, 0, 1);
}
int main()
{
#define int long long
    int T;
    cin >> T;
    shi[0] = 1;
    memset(dp, -1, sizeof(dp));
    for (int a = 1;a <= 20;a++)shi[a] = shi[a - 1] * 10;
    while (T--)
    {
        int n, m;
        cin >> n >> m;
        int yuy = jiejue(m) - jiejue(n - 1);
        cout << yuy << endl;
    }
    return 0;
}
基于DSP28335的Matlab/Simulink代码生成实验七:A/D采样 实验七:讲解如何使用DSP的ADC模块,通过代码生成技术控制DSP进行电流采样,是后续实现电机闭环控制的重要环节。通过简单的实验来熟悉代码生成的过程。最终实现复杂算法代码自动生成,进行高性能电机控制! 阅读详情

相关推荐

西门子交换机环网冗余设置(实战篇2.2)

MRP的重组时间为 200ms 因此 PROFINET 通信必须选择大于 200ms 的看门狗时间,看门狗。ET200SP默认为 2ms*3=6ms) MRP 的重组时间为 200ms 故系统会报出看门狗超时。更新,默认是 3 个周期,超出设置的周期数就会报 IO 设备故障。时间不是直接配置的,而是作为没有 IO 数据可接受的更新周期,也就是允许几个周期没有数据。来达到大于 200ms 的看门狗时间的要求(看门狗时间 可接受更新周期数 更新时间)。是IO 控制器和 IO 设备)

weixin_42580591的博客 388

2018上海acm————Beautiful Numbers——数位dp

链接:https://www.nowcoder.com/acm/contest/163/J 来源:牛客网   题目描述 NIBGNAUK is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is ...

wearegamer的博客 419

基于SVPWM控制策略的二极管钳位型NPC逆变器并网闭环simulink仿真

本文介绍了二极管钳位型三电平SVPWM技术在逆变器中的应用,通过控制IGBT的开关状态,将直流电压转换为三相交流电压,并采用钳位技术降低谐波失真,提高输出质量。文章还描述了基于SVPWM控制策略的二极管钳位型NPC逆变器并网闭环的Simulink仿真模型,该模型实现了并网控制,具有优异的性能,THD小于1%,适用于新手学习。仿真模型参数包括DC 800V、AC 380V、功率100kw,采用三电平NPC拓扑结构和SVPWM闭环控制策略,配备LCL滤波器,生成三电平波形,监测交流侧电压电流、有功功率和无功功率

2510_91195931的博客 476

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

题目描述 NIBGNAUK is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by the sum of its digits. We will not argue ...

kuronekonano的博客 342

通达信强龙趋势幅图指标 - 精准捕捉趋势,把握强势行情,多角度分析个股,强弱一目了然

STICKLINE(趋势>0 AND SJTJ,4.8,5.8,1.5,0),COLORYELLOW;STICKLINE(资金>0 AND SJTJ,1.2,2.2,1.5,0),COLOR0080FF;STICKLINE(异动>0 AND SJTJ,0,1,1.5,0),COLORFF0080;STICKLINE(异动=0 AND SJTJ,0,1,1.5,1),COLORGRAY;

Q1809330692的博客 5713

编译原理2024期末复习(面向做题,大题速学)【太原理工大学】

归约-归约”冲突就是在项目集规范族一个状态中两个。

m0_63181421的博客 1万+

CodeForces - 55D (数位dp)

 第一次做数位dp,套模板的,留着以后用。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;algorithm&gt; #include&lt;cstring&gt; #include&lt;cmath&gt; #include&lt;vector&gt; #include&lt;queue&gt; #include&am

blaze_jack 497

horizon之为connection服务器配置证书

打开connection1服务器(connection2 同connection1)再输入connection1的IP地址 可通过域名和IP地址进行登录。这时候用域名登录就发现证书已经没有警告了。win+R 调出“运行”,输入mmc。connection2 同上。如果还有报错请重启一下服务器。打开connection1。可以把这个先删掉 没用。打开DC_01服务器。右键选择证书颁发机构。友好名称只能是vdm。重启之后就没有报错了。

送个祝福给小豪的博客 2972

CodeForces - 55D (完美数)

Beautiful numbers Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digit

LP_Cong 1515

【Dynamo学习笔记】Dynamo for Revit建模基础

为了能和Revit进行交互,Dynamo中内置了很多Revit的节点,包含一系列用于选择、创建、编辑、查询等操作,帮助用户简化建模的过程,提高工作效率,拓展模型的应用。为了简化程序,我们可以将一些通用的节点流程编组封装成自定义节点。首先,我们选中我们需要封装的节点组,在空白处点击右键,选择创建自定义节点。

喵木木的博客 4442

innovus:sroute 双层follow pin的做法

根据std cellpower pin的层次可以分成两种情况。

m0_61544122的博客 2775

codeforce 55D D. Beautiful numbers(数位dp)

D. Beautiful numberstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVolodya is an odd boy and his taste is strange as well. It seems to him that a...

albertluf的博客 270

大模型系列——Ollama简明教程

在这篇文章中,我们将了解如何使用 Ollama、如何在 Ollama 中创建自己的模型 以及如何使用 Ollama 构建聊天机器人。这是深入研究 Ollama 的第一部分,以及我所学到的有关本地 LLM 的知识以及如何将它们用于基于推理的应用程序。在这篇文章中,你将了解——

2401_84052244的博客 1万+

codeforces 55D 数位DP

codeforces 55D 题意: 给定区间[l,r],限制条件:给定区间[l,r],限制条件:给定区间[l,r],限制条件: 该数能被任意数位上不为0的数整除该数能被任意数位上不为0的数整除该数能被任意数位上不为0的数整除 问区间内满足以上条件的数的个数。问区间内满足以上条件的数的个数。问区间内满足以上条件的数的个数。 题解: 首先将由1—9中若干数字的lcm的个数离散化为28。首先将...

Welcome to csdn_PatrickStar's blog 314

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

【数位DP】 【CodeForces 55D】

原题直通车: 题意:求区间[a, b]中有多少个数能整除自身的每个非0数位。 分析:一个数位只有1~9种可能,而1~9的lcm=2520。满足要求的数所有数位的lcm一定是2520的因子,       所以可先求出2520的所有因子,一开始都对2520取mod,这样对结果没有任何影响,最后再对所有数       位的lcm取mod,如果为0则满足。 代码: #include

PWZER 892

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

codeforces 55D

题目链接:http://codeforces.com/problemset/problem/55/D 需要维护三个数   个数count,满足条件数的和sum,数的平方和square; 一个数 = (a*10的pre次方+b);b 一个数的平方 = (a*10的pre次方*a*10的pre次方 + 2*a*10的pre次方*b + b*b); len时(len-1的数在nxt中)

observadores的博客 396

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

【CodeForces 55D】Beautiful number 数位DP

Problemhttps://vjudge.net/problem/CodeForces-55DSolutionhttp://blog.csdn.net/lhq_er/article/details/77017024 代码更新过了,这个链接里的只能做到101810^{18},这个能到9∗10189*10^{18}CODE/* * @key words: digit DP * @tested o

Lhq 359

数位dp CodeForces - 55D 美丽数字

Beautiful numbers CodeForces - 55D 题意:定义能被自己所有位数整除的数字为美丽,给定一个区间,求区间内的美丽数字个数。 分析:首先,可以把限制条件转化为之前所有位数的最大公倍数,将pos,sum,lcm,up当作 dfs的条件和dp下标,然后dp[ pos ][ sum ][ lca ][ up ] 就代表着 pos 之后的位置全部遍历...

aolian4963的博客 232

CodeForces 55 D 数位dp 数论 离散化

http://codeforces.com/problemset/problem/55/D 题意: 问从l到r之间有多少个数x满足x%mul(x[i])==0, 其中mul(x[i])表示x各个位上的数的乘积(除0外). 思路:数位dp 写着个题需要两个前置储备: 1: x对一系列的数的乘积(<x)取余 相当于 x对这一系列数的最小公倍数取余. 所有x的x[i]能得出的乘积最...

swqeaaa的博客 195

Codeforces-55D Beautiful numbers

数位DP 数学

a free man 663

CodeForces 55D Beautiful numbers(数位dp)

CodeForces 55D题目求给定区间内的能被自己的每一非零位整除的数的个数思路http://www.cnblogs.com/algorithms/archive/2012/09/02/2668021.html dp[pos][mod][lcm],pos表示当前位,mod表示对2520取模,lcm表示位数的最小公倍数,离散化,取2520等处理优化的很好。代码#include<iostream

天道酬勤 898

CodeForces - 55D Beautiful numbers

题目链接:http://codeforces.com/problemset/problem/55/D 题意:求区间[L,R]有多少个Beautiful numbers。Beautiful numbers为能被组成该数字的各个数字整除的数字。 思路:由于所有1-9数字的Lcm为2520。我们用f[i][j][k]表示到达第i位,前面的数字模2520的余数为j,前面数字的Lcm为k,那么最后j%k...

weixin_34161032的博客 122

CodeForces - 55D Beautiful numbers —— 数位DP

题目链接:https://vjudge.net/problem/CodeForces-55D D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard ou...

alince20008的博客 180

Codeforces 55D Beautiful Number

Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. Input The first line of the input contains the number of case...

weixin_30493321的博客 71

【codeforces】55D. Beautiful numbers 数位DP

传送门:【codeforces】55D. Beautiful numbers 题目分析:

poursoul 1064
上一篇: HDU3564 线段树+dp
下一篇: Codeforces Round #321 (Div. 2) D
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址