不要62 (记搜)
来源:互联网 发布:大数据修炼系统醉寒123 编辑:程序博客网 时间:2024/05/16 06:05
http://acm.hdu.edu.cn/showproblem.php?pid=2089
注意:
开始我是设的三维数组,但后来发现错了,因为当边界为1时,前面的dfs是不能应用的因为
它不是遍历所有可取区间;还有在ret处时,开始就直接判断了bound,其实是要同时判断bian和
bound因为只要其中一个为否,后面就可任意取。
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <map>#include <iostream>#include <stdexcept>#include <cstddef>#include <algorithm>#include <vector>#include <numeric>#include <cctype>#define LL long long#define Endl endl#define INF 0x7fffffff//#define WJusing namespace std;int vis[10][2];int shu[10];int dfs(int wei,bool liu,bool bian){if(wei==0) return 1;if(!bian&&vis[wei][liu]!=-1) return vis[wei][liu];int cnt=bian? shu[wei]:9;bool bound,six;int ret=0;for(int i=cnt;i>=0;i--){bound=(i==cnt? 1:0);six=(i==6? 1:0);if(i==2&&liu) continue;if(i==4) continue;ret+=dfs(wei-1,six,bound&&bian);}if(!bian)vis[wei][liu]=ret;return ret;}int qu(int x){int d=0;while(x){shu[++d]=x%10;x/=10;}return dfs(d,0,1);}int main(int argc, char *argv[]){#ifdef WJ//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);#endifint l,r;while(~scanf("%d%d",&l,&r)){if(!l&&!r) break;memset(vis,-1,sizeof(vis));printf("%d\n",qu(r)-qu(l-1));}return 0;}
0 0
- 不要62 (记搜)
- 不要62(hdu2089)
- 不要62(水)
- 不要62(数位DP)
- 不要62(数位DP)
- 不要62(数位DP)
- 不要62(数位Dp)
- superoj495 不要62(未完成)
- 不要62(数位DP)
- 不要62(数位dp)
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- ssh整合报错,nested exception is java.lang.NoSuchFieldError: TRACE
- Android:Layout_weight的深刻理解
- spark 1.1.0 on hadoop 2.4.1 安装笔记 (resourcemanager ha 支持)
- Hadoop2的ResourceManager高可用配置
- 每天一个linux命令(21):find命令之xargs
- 不要62 (记搜)
- spark网页资料
- spark应用程序的运行架构
- leetCode:Reverse Integer
- 优麒麟手机助手桌面技术细节
- GNUMakefiles之Makefiles变量的使用
- 高清网络机芯开发实战之缘起
- B-number(记搜)
- 32 应 用 笔 记