[暑假集训--数位dp]UESTC250 windy数】的更多相关文章

windy定义了一种windy数. 不含前导零且相邻两个数字之差至少为22 的正整数被称为windy数. windy想知道,在AA 和BB 之间,包括AA 和BB ,总共有多少个windy数? Input 包含两个整数,AA BB . 满足 1≤A≤B≤20000000001≤A≤B≤2000000000 . OutputSample Input 1 10 Sample Output 9 记一下上一位出现的数是啥 #include<cstdio> #include<iostream>…
A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this problem you will be given two integers i j, you have to find the number of palindromic numbers between i and j…
A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is placed at some digit of the number, the distance f…
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 current number sequence includes the sub-sequence "49", the power of the…
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task is to calculate how many wqb…
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众.不吉利的数字为所有含有4或62的号码.例如:62315 73418 88914都属于不吉利号码.但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列.你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了.   Input…
1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MB Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? Input 包含两个整数,A B. Output 一个整数 Sample Input [输入样例一] 1 10 [输入样例二] 25 50 Sample Output [输出样例…
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,RL,R . Input The input contains multiple test cases. The…
Jimmy writes down the decimal representations of all natural numbers between and including m and n, (m ≤ n). How many zeroes will he write down? Input Input starts with an integer T (≤ 11000), denoting the number of test cases. Each case contains two…
A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true" or "false" respectively). And every decimal number has a binary representation which is actually a series of bits. If a bit of a number is 1 a…
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 First line a t,then 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 num…
树上DP通常用到dfs https://www.cnblogs.com/mhpp/p/6628548.html POJ 2342 相邻两点不能同时被选 经典题 f[0][u]表示不选u的情况数,此时v可选可不选 f[1][u]表示选u的情况数,此时v不选 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> us…
区间DP 经典石子合并问题V1    复杂度 On3 int a[SZ], sum[SZ], f[SZ][SZ]; int main() { int n; scanf("%d", &n); ; i <= n; i++) { scanf("%d", &a[i]); sum[i] = sum[i-] + a[i]; } ; len <= n; len++) { ; l <= n-len+; l++) { ; int ans = INF;…
A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this problem you will be given two integers i j, you have to find the number of palindromic numbers between i and j…
Codeforces 148D 考虑状态转移..https://www.cnblogs.com/kuangbin/archive/2012/10/04/2711184.html题意:原来袋子里有w只白鼠和b只黑鼠,龙和王妃轮流从袋子里抓老鼠,谁先抓到白色老鼠谁就赢王妃每次抓一只老鼠,龙每次抓完一只老鼠之后会有一只老鼠跑出来.王妃先抓,如果两个人都没有抓到白色老鼠则龙赢,问王妃赢的概率 思路:设dp[i][j]表示现在轮到王妃抓时有i只白鼠,j只黑鼠,王妃赢的概率 明显 dp[0][j]=0,0<…
学了这么长时间的dp似乎还是不怎么样 谨以此篇文字记录一年以来与dp斗智斗勇的各种经历 关于dp(也就是动态规划)似乎对于每个OIer来说都是一个永远的噩梦. 刚刚开始学dp的时候完全搞不明白(只是觉得好厉害的样子) 完全停留在刚刚好能够看懂转移方程的阶段 事实上dp这个东西和其他任何算法都不太一样,同样是仅仅看不可能学会,但是更加可恶的一点是,你仅仅是看,不仅学不会,而且基本上什么东西都学不来. 说到底,毕竟哪个题都不一样,基本上不可能考到同样的题同样的转移方程(可惜当时并不明白这个道理).…
日常废话: 完了高一开学第二天作业就写不完了药丸(其实第一天就写不完了) 传传传传传送 显然爆搜肯定过不了这道题但是有60分 我们注意到在[1,n]中,有着相同的1的个数的数有很多.若有x个数有i个1,则对答案产生的贡献是\(i^x\).考虑到\(n\leq10^{50}\),所以最多只有50个1,看起来能够接受.这样问题就转化成求1~n内,二进制表示中有i个1的数的个数,可以用数位dp求. 关于\(i^x\),用快速幂搞一搞就好了. 数位dp using namespace std; type…
前言:鸣谢https://www.luogu.com.cn/blog/virus2017/shuweidp.感谢大佬orz ----------------------------- [引入] 首先要明白数位DP解决的是什么问题. 问题:求出在$[L,R]$内满足条件$f(i)$的$i$的个数.$f(i)$一般不与数的大小有关,而是与数的组成有关.(数的大小对复杂度的影响很小) [设计搜索] 数位DP一般都用记忆化搜索来实现. 一.记搜过程 从起点向下搜索,到最底层得到方案数,一层一层向上返回答…
思路  和普通的DP不一样的是 这里求的是满足条件的数的平方的和 而数位DP只跟数每位是什么密切相关  所以要开一个结构 (多加一个 数的和sum 和平方和qsum)存一下各个状态的和的情况 dp[pos][state1][state2].num  满足该状态的数有几个 dp[pos][state1][state2].sum 满足该条件的数的和是多少 dp[pos][state1][state2].qsum 满足该条件的数的平方的和是多少 详见注解 主要是状态转移是 和 和 平方和 的转移公式…
题目背景 SOURCE:NOIP2015-GDZSJNZX(难) 题目描述 Mike 正在在忙碌地发着各种各样的的短信.旁边的同学 Tom 注意到,Mike 发出短信的接收方手机号码似乎都满足着特别的性质,难道Mike 的好朋友是满足正态分布的?Tom 很好奇. 由于 Mike 有着自己最喜欢的数字 a ,并且 a 的范围是:2≤a≤9 .Tom 从这里入手,发现了一些端倪,假设 Mike 发的电话号码是一个十进制数字 S ,Tom 发现 S 会满足以下三个性质中的一个: 1.S 是 a 的倍数…
Description 人们选择手机号码时都希望号码好记.吉利.比如号码中含有几位相邻的相同数字.不含谐音不吉利的数字等.手机运营商在发行新号码时也会考虑这些因素,从号段中选取含有某些特征的号码单独出售.为了便于前期规划,运营商希望开发一个工具来自动统计号段中满足特征的号码数量. 工具需要检测的号码特征有两个:号码中要出现至少3个相邻的相同数字,号码中不能同时出现8和4.号码必须同时包含两个特征才满足条件.满足条件的号码例如:13000988721.23333333333.14444101000…
链接: 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…
1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 5230  Solved: 2353[Submit][Status][Discuss] Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? Input 包含两个整数,A B. Output 一个整数 Sample I…
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1026 分析: 简单的数位DP啦 f[i][j]表示数字有i位,最高位的数值为j的windy数总个数 那么f[i][j]=singma(f[i-1][k])(|j-k|>=2) 那么对于1~x(假设x从高到低的每位依次是x[n],x[n-1],……x[1])中的windy数个数就是f[n][0]+f[n][1]+……f[n][x[n]-1] + f[n-1][0]+f[n-1][1]+……f[…
1026: [SCOI2009]windy数 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=1026 Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? Input 包含两个整数,A B. Output 一个整数.…
1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 4550  Solved: 2039[Submit][Status][Discuss] Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? Input 包含两个整数,A B. Output 一个整数. Sample…
windy数 bzoj-1026 题目大意:求一段区间中的windy数个数. 注释:如果一个数任意相邻两位的差的绝对值都不小于2,这个数就是windy数,没有前导0.$区间边界<=2\cdot 10^9$. 想法:数位dp裸题,何为数位dp? 数位dp的意思就是我们交换一种dp的方式.通过数位进行dp.数位dp的主旨分为两点:1.对于所求答案的预处理.2.对于所求区间的边界特判.我们对于数位dp有几个显而易见但是却比较useful的性质: 如果一个数的位数小于第二个数的位数,那么后者是大于前者的…
BZOJ_1026_[SCOI2009]windy数_数位DP 题意:windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道, 在A和B之间,包括A和B,总共有多少个windy数? 学一下数位DP. f[i][j]表示i位数以j开头的windy数个数.转移有f[i+1][k]+=f[i][j](abs(j-k)>=2) 答案转成[1~R]-[1~L-1]之后按位枚举,每次枚举到当前位上的数减1. 注意: 1.枚举到两位差2以内时停止枚…
1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 8203  Solved: 3687[Submit][Status][Discuss] Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道, 在A和B之间,包括A和B,总共有多少个windy数? Input 包含两个整数,A B. Output 一个整数 Sample…