Jimmy writes down the decimal representations of all natural numbers between and including m and n, (m ≤ n). How many zeroes will he write down?

Input

Input starts with an integer T (≤ 11000), denoting the number of test cases.

Each case contains two unsigned 32-bit integers m and n, (m ≤ n).

Output

For each case, print the case number and the number of zeroes written down by Jimmy.

Sample Input

5

10 11

100 200

0 500

1234567890 2345678901

0 4294967295

Sample Output

Case 1: 1

Case 2: 22

Case 3: 92

Case 4: 987654304

Case 5: 3825876150

问 l 到 r 出现了几个0

记一下出现了几个0,有没有前导零就好

 #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[];
int zhan[],top;
inline LL dfs(int now,int dat,int tot,int lead,int fp)
{
if (now==)return tot;
if (!fp&&f[now][dat][tot][lead]!=-)return f[now][dat][tot][lead];
LL ans=,mx=fp?d[now-]:;
for (int i=;i<=mx;i++)
{
int nexlead=lead&&i==&&now-!=;
ans+=dfs(now-,i,tot+(i==&&!nexlead),nexlead,fp&&i==d[now-]);
}
if (!fp)f[now][dat][tot][lead]=ans;
return ans;
}
inline LL calc(LL x)
{
if (x<=)return x+;
LL xxx=x;
len=;
while (xxx)
{
d[++len]=xxx%;
xxx/=;
}
LL sum=;
for (int i=;i<=d[len];i++)
{
if (i)sum+=dfs(len,i,,,i==d[len]);
else sum+=dfs(len,,len==,,!d[len]);
}
return sum;
}
main()
{
int T=read(),cnt=;
while (T--)
{
l=read();r=read();
if (r<l)swap(l,r);
memset(f,-,sizeof(f));
printf("Case %d: %lld\n",++cnt,calc(r)-calc(l-));
}
}

LightOJ 1140

[暑假集训--数位dp]LightOJ1140 How Many Zeroes?的更多相关文章

  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]hdu5787 K-wolf Number

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

  7. [暑假集训--数位dp]UESTC250 windy数

    windy定义了一种windy数. 不含前导零且相邻两个数字之差至少为22 的正整数被称为windy数. windy想知道,在AA 和BB 之间,包括AA 和BB ,总共有多少个windy数? Inp ...

  8. [暑假集训--数位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 ...

  9. [暑假集训--数位dp]hdu5898 odd-even number

    For a number,if the length of continuous odd digits is even and the length of continuous even digits ...

随机推荐

  1. Git初始化仓库

    Git global setup: git config --global user.name "再见理想" git config --global user.email &quo ...

  2. Bootstrap历练实例:可取消的警告

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  3. jdk配置与环境变量配置

    1.1.下载jdk1.8.0,如图所示 解压放在你用的位置 在官网中下载 1.2.配置环境变量 打开环境变量:计算机-->属性-->高级系统配置-->环境变量 配置JAVA_HOME ...

  4. Tomcat详细安装配置

    1.首先是Tomcat的获取和安装. 获取当然得上Apache的官方网站下载,开源免费,而且带宽也足够.下载会很快. 这是两种不同的下载,一个是普通安装版本,一个是解压安装版本.使用起来是一样的,只是 ...

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

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

  6. 【转】再谈 最速下降法/梯度法/Steepest Descent

    转载请注明出处:http://www.codelast.com/ 最速下降法(又称梯度法,或Steepest Descent),是无约束最优化领域中最简单的算法,单独就这种算法来看,属于早就“过时”了 ...

  7. 到底该如何理解DevOps这个词

    炒了8年的概念,到底该如何理解DevOps这个词? 转载本文需注明出处:EAII企业架构创新研究院,违者必究.如需加入微信群参与微课堂.架构设计与讨论直播请直接回复公众号:“EAII企业架构创新研究院 ...

  8. jQuery获取动态添加的元素,live和on的区别

    今天给大家说一下如果用jQuery获取动态添加的元素,通常如果你在网页上利用jQuery添加一个元素,那么用平常的jQuery获取元素的方法无效的获取不到的.可以用以下的方法获取动态元素!假设我们现在 ...

  9. Python PyAudio 安装使用

    Python PyAudio安装: Python3.7 无法安装pyaudio pip install pyaudio提示error: Microsoft Visual C++ 14.0 is req ...

  10. Eclipse设置C++自动补全变量名快捷键

    用快捷键:Alt+/ 要是还是有些场合不能提示,按照下列步骤 Window-Preferences-c/c++-Editor-Content Assist-Advanced 将未勾选的全部勾选