水题 不要62 HDU 2089
先预处理出所有的数是不是可能拿来用,我的想法是记录1-i这个区间内可用的数为s[i].
输入a,b.答案就为s[b] - s[a-1].
贴代码:
#include<cstdio>
#define N 1000010
int sum[N];
bool check(int x)
{
while(x)
{
int t = x%;
if(t == ) return false;
if( t == && (x/%) == ) return false;
x /= ;
}
return true;
}
void init()
{
for(int i=; i<N-; ++i)
{
if(check(i)) sum[i] = sum[i-]+;
else sum[i] = sum[i-];
}
}
int main()
{
// freopen("in.c","r",stdin);
init();
int a,b;
while(~scanf("%d%d",&a,&b))
{
if(a== && b==) break;
printf("%d\n",sum[b]-sum[a-]);
}
return ;
}
水题 不要62 HDU 2089的更多相关文章
- [ACM_水题] 不要62(hdu oj 2089, 不含62和4的数字统计)
Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来, ...
- 不要62 hdu 2089 dfs记忆化搜索
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意: 给你两个数作为一个闭区间的端点,求出该区间中不包含数字4和62的数的个数 思路: 数位dp中 ...
- 数位DP入门(A - 不要62 HDU - 2089 &&B - Bomb HDU - 3555 )
题目链接:https://cn.vjudge.net/contest/278036#problem/A 具体思路:对于给定的数,我们按照位数进行运算,枚举每一位上可能的数,在枚举的时候需要注意几个条件 ...
- Day9 - I - 不要62 HDU - 2089
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍, ...
- A - 不要62 HDU - 2089
#include<stdio.h> #include<string.h> #include<math.h> #include<time.h> #incl ...
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 2096 小明A+B --- 水题
HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...
- [HDU 2602]Bone Collector ( 0-1背包水题 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...
随机推荐
- Linux 之 ./configure --prefix 命令
参考 http://blog.sina.com.cn/s/blog_406127500101dsmy.html 源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(mak ...
- English trip -- VC(情景课) 7 C How much are the shose? 鞋多少钱
Grammar focus 语法点: How much is ...? How much are...? How much is the shirt? $15.99. How much are ...
- codeforces 484a//Bits// Codeforces Round #276(Div. 1)
题意:给出区间[ll,rr],求中间一个数二进制表示时一的个数最多. 写出ll和rr的二进制,设出现第一个不同的位置为pos(从高位到低位),找的数为x,那么为了使x在[ll,rr]内,前pos-1个 ...
- Working routine CodeForces - 706E (链表)
大意: 给定矩阵, q个操作, 每次选两个子矩阵交换, 最后输出交换后的矩阵 双向十字链表模拟就行了 const int N = 1500; int n, m, q; struct _ { int v ...
- .net 环境配置
需要把安装中文包也安装上.4个都安装
- sql server数据库中char、nchar、varchar、nvarchar的选择
在数据库中,字符型的数据是最多的,可以占到整个数据库的80%以上.为此正确处理字符型的数据,对于提高数据库的性能有很大的作用. 在字符型数据中,用的最多的就是Char与Varchar两种类型.前面的是 ...
- Eclipse偏好设置的导入与导出
偏好导入:File--->Import
- Netty高性能编程备忘录(下)
估计很快就要被拍砖然后修改,因此转载请保持原文链接,否则视为侵权... http://calvin1978.blogcn.com/articles/netty-performance.html 前文再 ...
- Mysql 中Left/Right join on后面and和where条件查询的差异-Mysql SQL运算符是有优先级
一.Mysql中Left/Right join on后面and和where条件查询的差异 1.建两张测试表,一张商户定义表.一张商户操作状态明细表 1)商户定义表 CREATE TABLE hope. ...
- 基于struts2和hibernate的登录和注册功能——完整实例
1.该项目使用MySQL数据库,数据库名为test,表名info,如图所示: 2.配置web.xml(Struts2使用) <?xml version="1.0" encod ...