HDU 2089 简单数位dp
1、HDU 2089 不要62 简单数位dp
2、总结:看了题解才敲出来的,还是好弱。。
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std; int dp[][]; //dp[i][j]表示以j为首位符合条件的i位数的个数 void init() //预处理
{
memset(dp,,sizeof(dp));
dp[][]=;
for(int i=;i<;i++){
for(int j=;j<;j++){ //枚举第i位
for(int l=;l<;l++){ //枚举第i-1位
if(j!=&&(!(j==&&l==))){
dp[i][j]+=dp[i-][l];
}
}
}
}
} int cal(int num)
{
int a[],k=,sum=;
while(num){
a[++k]=num%;
num/=;
} a[k+]=;
for(int i=k;i>;i--){
for(int j=;j<a[i];j++){
if(j!=&&!(a[i+]==&&j==)){
sum+=dp[i][j];
}
}
if(a[i]==||(a[i+]==&&a[i]==)){ //因为是从首位开始,如果前面已经不符合,后面就没必要进行了
break;
}
} return sum;
} int main()
{
init();
int n,m;
while(scanf("%d%d",&n,&m)!=EOF,n&&m)
{
printf("%d\n",cal(m+)-cal(n)); //cal函数没有考虑到num本身
} return ;
}
HDU 2089 简单数位dp的更多相关文章
- HDU5898、 HDU 2089(数位DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5898 题意:很明确,找出区间[l , r]中符合连续奇数为偶数,连续偶数为奇数的个数. 思路:dp[i ...
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- hdu 2089 入手数位dp问题
数位dp解决的问题是指求在一段数的区间里面 满足条件的数的个数 核心为两点 http://wenku.baidu.com/link?url=tpfIYzhx_MzevpIM58UZ66pr-87MCF ...
- HDU(2089),数位DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2089 不要62 Time Limit: 1000/1000 MS (Java/Others ...
- Bomb HDU - 3555 (数位DP)
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...
- HDU(4734),数位DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4734 F(x) Time Limit: 1000/500 MS (Java/Others) ...
- HDU(3555),数位DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others ...
- HDU 3555 Bomb 数位dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...
- HDU 3853LOOPS(简单概率DP)
HDU 3853 LOOPS 题目大意是说人现在在1,1,需要走到N,N,每次有p1的可能在元位置不变,p2的可能走到右边一格,有p3的可能走到下面一格,问从起点走到终点的期望值 这是弱菜做的第 ...
随机推荐
- 知乎大牛的关于JS解答
很多疑惑一扫而空.... http://www.zhihu.com/question/35905242?sort=created JS的单线程,浏览器的多进程,与CPU,OS的对位. 互联网移动的起起 ...
- HDU3359 Kind of a Blur(高斯消元)
建立方程后消元 #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring& ...
- WebStorm 有哪些过人之处?
作者:方应杭链接:https://www.zhihu.com/question/20936155/answer/16654794来源:知乎著作权归作者所有,转载请联系作者获得授权. 先说缺点吧: 常驻 ...
- 信号量进程同步,王明学learn
信号量进程同步 一组并发进程进行互相合作.互相等待,使得各进程按一定的顺序执行的过程称为进程间的同步. 信号量在进程同步时初始值为:0 信号量在进程互斥时初始值为:大于0的 本章节主要使用信号量,使的 ...
- Android 大牛的 blog 值得推荐 (转 整理)
1 收集了 国外著名开发者 25 人,包括 Github 地址.Blog 地址以及重点贡献介绍 链接 收集了 国内部分开发者 32人,包括 Github 地址.Blog 地址以及重点贡献介绍, 链接 ...
- ubuntu kylin中如何截图
windows操作系统中,我通常使用的截图工具是QQ的“ctrl+alt+a”快捷键.但是在ubuntu中,linux qq常年不更新,我也就彻底放弃了使用了,反正ubuntu通常只是拿来开发.其实没 ...
- Strust2 初体验
Struts2的第一个案例 首先我们需要引入架包 entity: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package ...
- IM服务器的架构
一. 总的构架结构示意图: 如上图所示,目前系统总的分成六个模块, 分别为网络/协议解析模块,用户帐号管理模块,消息处理模块,动作处理模块,数据均衡处理模块,客户状态处理模块 . 正常流程应该这么实现 ...
- cdoj1324暴力分块
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> ...
- poj2796 维护区间栈//单调栈
http://poj.org/problem?id=2796 题意:给你一段区间,需要你求出(在这段区间之类的最小值*这段区间所有元素之和)的最大值...... 例如: 6 3 1 6 4 5 2 以 ...