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>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL n,len,l,r;
LL f[][][];
int d[];
inline LL dfs(int now,int dat,int lead,int fp)
{
if (now==)return (!lead)||(lead&&dat==);
if (!fp&&f[now][dat][lead]!=-)return f[now][dat][lead];
LL ans=,mx=fp?d[now-]:;
for (int i=;i<=mx;i++)
{
if (!lead&&(i==dat-||i==dat||i==dat+))continue;
ans+=dfs(now-,i,lead&&i==&&now-!=,fp&&i==d[now-]);
}
if (!fp)f[now][dat][lead]=ans;
return ans;
}
inline LL calc(LL x)
{
if (!x)len=,d[len]=;
else
{
LL xxx=x;
len=;
while (xxx)
{
d[++len]=xxx%;
xxx/=;
}
}
LL sum=;
sum+=dfs(len,,,);
for (int i=;i<=d[len];i++)
sum+=dfs(len,i,,i==d[len]);
return sum;
}
int main()
{
while (~scanf("%lld%lld",&l,&r))
{
memset(f,-,sizeof(f));
printf("%lld\n",calc(r)-calc(l-));
}
}

UESTC 250

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

  1. [暑假集训--数位dp]LightOj1205 Palindromic Numbers

    A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the sam ...

  2. [暑假集训--数位dp]hdu3709 Balanced Number

    A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. ...

  3. [暑假集训--数位dp]hdu3555 Bomb

    The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...

  4. [暑假集训--数位dp]hdu3652 B-number

    A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- ...

  5. [暑假集训--数位dp]hdu2089 不要62

    杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍, ...

  6. 数位dp——BZOJ1026 Windy数

    1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MB Description windy定义了一种windy数.不含前导零且相邻 ...

  7. [暑假集训--数位dp]hdu5787 K-wolf Number

    Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation o ...

  8. [暑假集训--数位dp]LightOJ1140 How Many Zeroes?

    Jimmy writes down the decimal representations of all natural numbers between and including m and n, ...

  9. [暑假集训--数位dp]LightOj1032 Fast Bit Calculations

    A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true&quo ...

随机推荐

  1. 团队作业——项目Alpha版本发布

    ---恢复内容开始--- https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1   https://edu.cnblogs.com ...

  2. Hicharts图表的使用

    Hicharts图表的使用 引用 在4.0之后就不需要jQuery了,z这里是用ajax向后台发送数据 引入js或者CDN,这里采用的是引入js的方式 在Hicarts文件中的index中查看相应的图 ...

  3. atoi 函数实现

      要考虑的东西实在也挺多的.总结如下:   1 前面空格分隔符号的时候   2 第一个符号位处理+ -   3 遇到非数字字符退出   4 为正数的时候,大于INT_MAX上溢   5 为负数的时候 ...

  4. javaweb基础(17)_jsp九个内置对象

    一.JSP运行原理 每个JSP 页面在第一次被访问时,WEB容器都会把请求交给JSP引擎(即一个Java程序)去处理.JSP引擎先将JSP翻译成一个_jspServlet(实质上也是一个servlet ...

  5. (转发)IOS动画中的枚举UIViewAnimationOptions

    若本帖转自(博客园·小八究):http://www.cnblogs.com/xiaobajiu/p/4084747.html 可怜目前天朝搜不到什么有价值的东西方便学习,在这里方便初学者. 首先这个枚 ...

  6. 【转】Matlab的regionprops详解

    matlab函数_连通区域 1. matlab函数bwareaopen──删除小面积对象格式:BW2 = bwareaopen(BW,P,conn)作用:删除二值图像BW中面积小于P的对象,默认情况下 ...

  7. redis学习笔记(1)

    最近在学习redis,做了比较详细的学习笔记,分享给大家,欢迎一起讨论和学习 第一部分,简单介绍redis 和 redis的基本操作 NoSQL的特点 : 数据库种类繁多,但是一个共同的特点都是去掉关 ...

  8. Linux安装配置***客户端

    1.创建root用户 sudo passwd root su root 2.安装shadowsocks sudo apt-get install python-pip sudo pip install ...

  9. day14-推导式和生成器表达式

    1.推导式规则 [每一个元素或者是和元素相关的操作 for 元素 in 可迭代数据类型] ----------遍历之后挨个处理[满足条件的元素相关的操作 for 元素 in 可迭代数据类型 if 元素 ...

  10. python基础学习笔记——反射

    对编程语言比较熟悉的朋友,应该知道“反射”这个机制.Python作为一门动态语言,当然不会缺少这一重要功能.然而,在网络上却很少见到有详细或者深刻的剖析论文.下面结合一个web路由的实例来阐述pyth ...