题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5179 bc(中文): http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=569&pid=1002 题解: 1.数位dp dp[i][j]表示第i位的数值为j的时候所有合法的情况,转移方程为dp[i][j]+=dp[i-1][k](j%k==0)数位最多为10位,可以离线处理出来. 计算1到x(x十进制按…
beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 801    Accepted Submission(s): 518 Problem Description Let A=∑ni=1ai∗10n−i(1≤ai≤9)(n is the number of A's digits). We call A as “…
原题链接 题意:求[l,r]中高位%低位等于0的数字个数.(不含0)分析:此题有三种方法.1.暴搜,毕竟最多才10个位.2.数位dp,预处理好整体的,再处理细节. dp[i][j]表示第i位上的数字位j的情况数,dp[i][j]+=dp[i-1][k](j%k==0) 3.猜想这样的数字并不多,于是打表. 数位dp #include <cstdio> #include <iostream> #include <cmath> #include <algorithm&…
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 pre:上一位的奇偶性 status:截止到上一位的连续段的奇偶性 ze:是否有前导0 /************************************************************** Problem:hdu 5898 odd-even number User: yo…
题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful number.问区间[a,b]上有多少个beautiful number.如102就是一个beautiful number,因为它能整除1,2.14不是,因为14不能整除4. 解法: 数位DP,设dp[i][j][k]为累计到第i为,公倍数为j,模lcm(1,2,```,9)=2520的余数为k的数的个…
beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​​(1≤a​i​​≤9)(nn为AA的位数).若AA为“漂亮的数”当且仅当对于任意1 \leq i < n1≤i<n满足a[i] \geq a[i+1]a[i]≥a[i+1]且对于任意1 \leq i \leq n,i < j \leq n1≤i≤n,i<j≤n,满足a[i]a[i]…
K-wolf Number Problem Description   Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different.Given (L,R,K), please count how many K-wolf numbers in range of [L,R].   Input   The in…
Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3798    Accepted Submission(s): 1772 Problem Description A balanced number is a non-negative integer that can be balanced if a pi…
Problem Description For a number,if the length of continuous odd digits is even and the length of continuous even digits is odd,we call it odd-even number.Now we want to know the amount of odd-even number between L,R(1<=L<=R<= 9*10^18).    Input…
题目链接 题意:一个数字,它每个数位上的奇数都形成偶数长度的段,偶数位都形成奇数长度的段他就是好的.问[L , R]的好数个数. 题解:裸的数位dp, 从高到低考虑每个数位, 状态里存下到当前位为止的值的奇偶性和长度奇偶性即可. #include <iostream> #include <vector> #include <string.h> #include <stdio.h> #include <queue> using namespace…
题意 给出一个二进制数\(n\),每次操作可以将一个整数\(x\)简化为\(x\)的二进制表示中\(1\)的个数,如果一个数简化为\(1\)所需的最小次数为\(k\),将这个数叫做特殊的数, 问从\(1\)到\(n\)一共有多少个特殊的数,答案对\(1e9+7\)取模. 分析 \(n\)最大为\(2^{1000}\),二进制表示中最多有\(1000\)个\(1\),所以\(n\)以内的数经过一次简化后将变为\(1000\)以内的数,我们可以暴力打表\(1000\)以内的数简化为\(1\)所需的最…
题目大意: 求  1(m)到n直接有多少个数字x满足 x可以整出这个数字的每一位上的数字 思路: 整除每一位.只需要整除每一位的lcm即可 但是数字太大,dp状态怎么表示呢 发现 1~9的LCM 是2520 ....也就是说只要对这个数mod2520 剩下的余数能整除lcm就可以整除了.. 计数的时候还有一个技巧,具体见注释 此外这个题还卡常数了,预处理lcm才过了.. 代码如下: #include <iostream> #include <stdio.h> #include<…
题意:  求高位往低位递减且  高位%低位==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…
题意: 一个如果称作是漂亮数,当且仅当满足: 每一位上的数字是[1,9],从高到时低数字大小降序,且有di%dj=0(i<j) 例:931 给一个区间[L,R],问这个区间里有多少个漂亮数. 1≤L≤R≤109 思路: 漂亮数一看就很少.可以直接构造. 哎,,,用了DP+构造,写了好久...其实很简单的一个DFS构造就行了. 过些天补上代码.先贴冗长代码~ 代码: int T,L,R; int wei; int ans1,ans2,ans; int d[15], w[15]; int dp[15…
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/J?&headNav=acm来源:牛客网 时间限制:C/C++ 8秒,其他语言16秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 NIBGNAUK is an odd boy and his taste is strange a…
// 多校5 HDU5787 K-wolf Number 数位DP // dp[pos][a][b][c][d][f] 当前在pos,前四个数分别是a b c d // f 用作标记,当现在枚举的数小于之前的数时,就不用判断i与dig[pos]的大小 // 整体来说就,按位往后移动,每次添加后形成的数都小于之前的数,并且相邻k位不一样,一直深搜到cnt位 // http://blog.csdn.net/weizhuwyzc000/article/details/52097690 // #prag…
普通的数位DP计算回文串个数 /* HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 2-36进制下回文串个数 */ #include <bits/stdc++.h> using namespace std; #define LL long long int t, L, R, l, r, base; int dig[40], tmp[40]; LL dp[40][40][40][2]; LL DFS(int p…
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: 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…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5179 题意:给你一个范围,问你漂亮的数有多少个,漂亮的数的定义为 数位高的比数位低的大,并且 数位高的数%数位低的数为0 题解:数位DP,详细看代码,为了方便,我把所有的参数全部设为了状态,这样就不用判断了 #include<cstdio> #include<cstring> #define F(i,a,b) for(int i=a;i<=b;i++) ],len,dp[][][…
B. Fi Binary Number     A Fi-binary number is a number that contains only 0 and 1. It does not contain any leading 0. And also it does not contain 2 consecutive 1. The first few such number are 1, 10, 100, 101, 1000, 1001, 1010, 10000, 10001, 10010,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the curre…
链接: 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…
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits:  200000 KB 64-bit interger IO format:  %lld   Java class name:  Main Description A Hill Number is a number whose digits possibly rise and then possibl…
Accept: 189    Submit: 461Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description One integer number x is called "Mountain Number" if: (1) x>0 and x is an integer; (2) Assume x=a[0]a[1]...a[len-2]a[len-1](0≤a[i]≤9, a[0] is posit…
Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 11804    Accepted Submission(s): 4212 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorist…
题目链接:hdu 5106 Bits Problem 题目大意:给定n和r,要求算出[0,r)之间全部n-onebit数的和. 解题思路:数位dp,一个ct表示个数,dp表示和,然后就剩下普通的数位dp了.只是貌似正解是o(n)的算法.可是n才 1000.用o(n^2)的复杂度也是够的. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意:求[n, m]区间内不含4和62的数字个数. 这题有两种思路,直接数位dp和dfs 数位dp: dp[i][j]表示i位数,首位是j的符合要求的数字个数. j = 4时    dp[i][j] = 0 j != 4时   例如求dp[3][2],2xx的个数,2已经确定了,2后面xx的个数即为2xx的个数,只用求出0x, 1x, 2x...9x的个数之和即可.同时要注意限制条件,dp[i…
Mountain Number One integer number x is called "Mountain Number" if: (1) x>0 and x is an integer; (2) Assume x=a[0]a[1]...a[len-2]a[len-1](0≤a[i]≤9, a[0] is positive). Any a[2i+1] is larger or equal to a[2i] and a[2i+2](if exists). For exampl…