Beautiful numbers CodeForces - 55D】的更多相关文章

题意: 找出区间[li,ri]内有多少数满足,这个数的每一个位的非0数都能把这个数整除 题解: 因为这个数每一位的值都可以把这个数整除,那也就是说这个数是它所有位数的公倍数,但是可能不是最小公倍数. 1.2.3.4.5.6.7.8.9的最小公倍数是2520 那么我就可以让我们要判断的那个数去取余2520来实现我们记忆化操作 因为1--9的最小公倍数是2520,所以1--9中任意几个数的最小公倍数肯定是2520的余数,所以我们只需要找出来1--2520之中所有2520的余数就可以了.最后找出来也就…
题意:一个数能整除它所有的位上的数字(除了0),统计这样数的个数. 注意离散化,为了速度更快需存入数组查找. 不要每次memset,记录下已有的长度下符合条件的个数. 数位dp肯定是从高位到低位. 记录数字已经有多大,还有lcm,递归传下去. #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include…
传送门 参考资料: [1]:CodeForces 55D Beautiful numbers(数位dp&&离散化) 我的理解: 起初,我先定义一个三维数组 dp[ i ][ j ][ k ]:来到 i 位置时,所有非零数的lcm = j,当前数位 k 时含有的 Beautiful numbers 的个数. 但是,由题意得,当前的数 k 可以是个很大的数(9e18),数组根本就开不下,那怎么办呢? 将当前的数 hash 一下,如何hash呢? 假设 a,b,c,d 为[0,9]的数,那么不存…
Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得只需要记录搜到当前位出现了哪些数字作为状态即可,明显是假算法...感觉这是一道数位DP好题.可以这样思考:一个数要想被其各位数字分别都整除,等价于它被那些数字的LCM整除.因此记录当前位,当前数对(1~9的LCM)取模的结果,当前出现的数字的LCM这三个值作为状态才合理,即dp[pos][sum][…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
题目链接: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 output Volodya is an odd boy and his taste is strange as well. It seems to him…
链接: https://vjudge.net/problem/CodeForces-55D 题意: 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…
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 cases t (1 ≤ t ≤ 10). Each of the next t lines contains two…
[codeforces 55]D. 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 digits. We will not argue with this and…
C. Beautiful Numbers 题目连接: http://www.codeforces.com/contest/300/problem/C Description Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains…
D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/D Description 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 i…
[Codeforces-div.1 55D] Beautiful numbers 试题分析 还是离散化...\(f_{i,j,k}\)表示i位,gcd为j,余数为k. #include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<algorithm> using namespace std; #define LL long long inline L…
来源:http://codeforces.com/problemset/problem/1265/B   B. Beautiful Numbers   You are given a permutation p=[p1,p2,…,pn]p=[p1,p2,…,pn] of integers from 11 to nn . Let's call the number mm (1≤m≤n1≤m≤n ) beautiful, if there exists two indices l,rl,r (1≤l…
题意: 如果一个数能被自己各个位的数字整除,那么它就叫 Beautiful numbers.求区间 [a,b] 中 Beautiful numbers 的个数. 分析:先分析出,2~9 的最大的最小公倍数是 2520({5,7,8,9}),先预处理出所有可能的最小公倍数m[c] dp[i][d][c]表示长度i, 余数d,各位上的数的最小公倍数是m[c]的个数. #include<cstdio> #include<cstring> #define mod 2520 ll dp[][…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
C. Beautiful Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal…
题目 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…
题目来源:http://codeforces.com/problemset/problem/55/D 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 wit…
C. Beautiful Numbers Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 524288/262144K (Java/Other) Total Submission(s) : 27   Accepted Submission(s) : 7 Problem Description Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly…
题目链接:http://codeforces.com/problemset/problem/55/D D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to…
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 num…
http://codeforces.com/problemset/problem/55/D Beautiful Numbers : 这个数能整除它的全部位上非零整数.问[l,r]之间的Beautiful Numbers的个数. 若一个数能整除它的全部的非零数位.那么相当于它能整除个位数的最小公倍数. 因此记忆化搜索中的參数除了len(当前位)和up(是否达到上界),有一个prelcm表示前面的数的最小公倍数.推断这个数是否是Beautiful Numbers,还要有一个參数表示前面数,可是这个数…
Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n. Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom…
D - Beautiful Graph CodeForces - 1093D You are given an undirected unweighted graph consisting of nn vertices and mm edges. You have to write a number on each vertex of the graph. Each number should be 11, 22or 33. The graph becomes beautiful if for…
题目链接: http://poj.org/problem?id=2117 题目大意:统计一个范围内数的个数,要求该数能被各位上的数整除.范围2^64. 解题思路: 一开始SB地开了10维数组记录情况. 首先要求能被各位上的数整除,可以转化为被一个数整除问题. 这个数就是各位上数的最小公倍数LCM(不是GCD). 其次,处理整除问题,得转化成数位DP的余数模板.1~9的LCM最大是2520, 那么%2520,让其可以开数组进行记忆化搜索. 最后, 对于不能%2520最后结果,再%各个数位累计过来的…
链接:https://ac.nowcoder.com/acm/problem/17385来源:牛客网 题目描述 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…
目录 Beautiful Numbers PROBLEM 题目描述 输入描述: 输出描述: 输入 输出 MEANING SOLUTION CODE Beautiful Numbers PROBLEM 题目描述 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 divisib…
CF55D Beautiful numbers 题意 \(t(\le 10)\)次询问区间\([l,r](1\le l\le r\le 9\times 10^{18})\)中能被每一位上数整除的数的个数,0算可以整除任何数. 最开始写了个假做法,既没算0复杂度也是假的 最开始把每个模数都压进去了,后来发现只压2520就可以了 然后前两位压前\(i\)位与\(\bmod 2520\)的结果,第三位最开始压了每个数字出现集合,这样就很屑. 可以直接压数字集合的最小公倍数,仅有不到50个取值,做一个H…
D. Beautiful numbers 链接 题意: 求[L,R]中多少个数字可以整除它们的每一位上的数字. 分析: 要求模一些数字等于0等价于模它们的lcm等于0,所以可以记录当前出现的数字的lcm,最后判断组成的数字是否模lcm等于0. 但是这个数字太大记录不下.根据一个性质a%b=(a%kb)%b,所以可以记录当前的数字模2520的值,最后模一下lcm. 这样的状态是$20 \times 2520 \times 2520$的,状态太大了,考虑如何缩小空间.因为1~9的lcm只能是50个左…