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. 2018.4.21 如何正确快速安装/卸载云服务器Centos7安装GUI图形化界面GNOME桌面环境

    为云服务哦Centos安装图形化界面GNOME .KDE 1.开始前先验证一下能不能上网 ping www.baidu.com 2.接下来开始安装X(X Window System),命令为 yum ...

  2. SC || Chapter 5 复习向

    可复用性 ┉┉∞ ∞┉┉┉┉∞ ∞┉┉┉∞ ∞┉┉ 行为子结构 对于父子的继承关系的要求: ·子类可以增加方法,但不可以删 ·子类需实现抽象类型中未实现的方法 ·子类重写(override)的方法必须 ...

  3. React组件间通信

    众所周知,ReactJS组件与组件之间的通信是一个难点.在React实际开发中,父子组件之间的传值是比较常见的,刚入门的小伙伴很容易被组件之间的通信绕懵. 今天花了点时间总结了一下React父子组件之 ...

  4. JavaScript操作DOM

    1.DOM对象简介: 什么是DOM:(Document Object Model) 译为文档对象模型,是 HTML 和 XML 文档的编程接口.   2.DOM HTML 节点树:指的是DOM中为操作 ...

  5. C++内存溢出和内存泄漏?

    1.内存溢出 内存溢出是指程序在申请内存时没有足够的内存空间供其使用.原因可能如下: (1)内存中加载的数据过于庞大: (2)代码中存在死循环: (3)递归调用太深,导致堆栈溢出等: (4)内存泄漏最 ...

  6. vs2005无法附加到进程 系统找不到文件

    用管理员身份打开vs2005. 注意配置.

  7. mysql 备份 常用脚本

    全备: innobackupex --defaults-file=/data/mysql3316/my3316.cnf --user=root --password=mysqlpass /data/b ...

  8. 02等待单个线程返回WaitForSingleObject

    windows 多线程之等待线程返回 ​ 多线程编程中,有时我们需要等待某一线程完成了特定的操作之后再继续做其他事情,要实现这个目的,可以使用 Windows API 函数 WaitForSingle ...

  9. pandas时间数据的集成处理

    工作中遇到的一个问题: 统计各地区新能源汽车的充电时长 数据来源是北理新源的单日全球的运行数据. 这里仅统计北上广重庆四个地区的 数据处理的代码就省略了 需要整理好的是4个dataframe(数据已保 ...

  10. python模块之datetime

    相比于time模块,datetime模块的接口则更直观.更容易调用 datetime模块定义了下面这几个类: datetime.date:表示日期的类.常用的属性有year, month, day: ...