学了这么长时间的dp似乎还是不怎么样 谨以此篇文字记录一年以来与dp斗智斗勇的各种经历 关于dp(也就是动态规划)似乎对于每个OIer来说都是一个永远的噩梦. 刚刚开始学dp的时候完全搞不明白(只是觉得好厉害的样子) 完全停留在刚刚好能够看懂转移方程的阶段 事实上dp这个东西和其他任何算法都不太一样,同样是仅仅看不可能学会,但是更加可恶的一点是,你仅仅是看,不仅学不会,而且基本上什么东西都学不来. 说到底,毕竟哪个题都不一样,基本上不可能考到同样的题同样的转移方程(可惜当时并不明白这个道理).…
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…
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通常用到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;…
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…