#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<iostream>
#include<ctype.h>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
using namespace std;
#define LL long long
LL dp[][],num[];
LL dfs(int pos,int iszero,int st,int limit)//pow为数位,iszero判断是否为0,st上一个状态初始为0,limit是否达到上限
{
if(pos<)
{
if(iszero)
return ;
else
return st;
}
if(!limit&&!iszero&&dp[pos][st]!=-)
return dp[pos][st];
LL ans=;
int len=limit?num[pos]:;
for(int i=;i<=len;i++)
{
if(iszero)
ans+=dfs(pos-,i==,,limit&&i==len);
else
ans+=dfs(pos-,,st+(i==),limit&&i==len);
}
if(!limit&&!iszero)
dp[pos][st]=ans;
return ans; }
LL sv(LL a)
{
int len=;
memset(dp,-,sizeof(dp));
memset(num,,sizeof(num));
while(a)
{
num[len++]=a%;
a/=;
}
return dfs(len-,,,);
}
int main()
{
LL m,n;
while(~scanf("%lld%lld",&n,&m))
{
// LL ee=sv(m)-sv(n-1);
printf("%lld\n",sv(m)-sv(n-));
} }

How Many Zeroes? LightOJ - 1140的更多相关文章

  1. 数位dp(D - How Many Zeroes? LightOJ - 1140 )

    题目链接:https://cn.vjudge.net/contest/278036#problem/D 题目大意:T组测试数据,每一次输入两个数,求的是在这个区间里面,有多少个0,比如说19203包括 ...

  2. lightoj 1140 - How Many Zeroes?(数位dp)

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

  3. LightOJ 1140 How Many Zeroes

    题意:写出一个给定区间的每个数,求出一共写了多少个零. 解法:数位DP,定义dp[len][flag][num]:len的定义为数位的长度,flag定义为前导0和没有前导0的两种状态,num定义为写的 ...

  4. LightOJ 1140: How Many Zeroes? (数位DP)

    当前数位DP还不理解的点: 1:出口用i==0的方式 2:如何省略状态d(就是枚举下一个数的那个状态.当然枚举还是要的,怎么把空间省了) 总结: 1:此类DP,考虑转移的时候,应当同时考虑查询时候的情 ...

  5. LightOJ 1140 How Many Zeroes? (数位DP)

    题意:统计在给定区间内0的数量. 析:数位DP,dp[i][j] 表示前 i 位 有 j 个0,注意前导0. 代码如下: #pragma comment(linker, "/STACK:10 ...

  6. LightOJ 1140 计数/数位DP 入门

    题意: 给出a,b求区间a,b内写下过多少个零 题解:计数问题一般都会牵扯到数位DP,DP我写的少,这道当作入门了,DFS写法有固定的模板可套用 dp[p][count] 代表在p位 且前面出现过co ...

  7. LightOJ - 1140 统计0的数位 数位DP

    注意以下几点: 搜索维度非约束条件的都要记录,否则大概率出错,比如_0 st参数传递和_0的互相影响要分辨清楚 num==-1就要返回0而不是1 #include<iostream> #i ...

  8. Lightoj 1140(数位DP)

    求一个区间内的数含有多少个0. dp[len][pre]表示长度为len的数,含有pre个0. 需要加一个标记,来表示前缀是否为0(可以是一串连续的0),如果前缀一直为0,就一直搜,如果前缀不为0,就 ...

  9. LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

    http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     M ...

随机推荐

  1. 【LeetCode每天一题】Plus One(加一)

    Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The d ...

  2. 2019年新软件发布分享HanGi.IT.AStrutTie.v2017 1CD

    Steelray Project Viewer 2019.1.69 1CDIAR Embedded Workbench for Renesas M16C-R8C v3.71.1 1CD Mentor ...

  3. - configuration.module has an unknown property 'loader' 问题解决

    错误提示: Invalid configuration object. Webpack has been initialised using a configuration object that d ...

  4. selenium--鼠标事件

    鼠标事件perform() #执行所有ActionChains中存储的行为context_click() #右击事件double_click() #双击事件drag_and_drop(source,t ...

  5. .htaccess使用方法介绍

    1..htaccess文件使用前提 .htaccess的主要作用就是实现url改写,也就是当浏览器通过url访问到服务器某个文件夹时,作为主人,我们可以来接待这个url,具体地怎样接待它,就是此文件的 ...

  6. git----------如何安装gitlab,使用步骤。

    1.配置yum源        vim /etc/yum.repos.d/gitlab-ce.repo 2.复制以下内容到打开的文件中: [gitlab-ce]     name=Gitlab CE ...

  7. Fiddler抓包【2】_捕获设置

    1.Fiddler抓web网站请求 手动设置方法一:Tools--->WinINET Options--->连接--->局域网设置--->代理服务器勾选后“高级”---> ...

  8. SecureCRT通过密钥登录(网上也有很多教程,但是有些不详细,此教程本人亲测)

    1.先打开SecureCRT,标题标--工具---创建公钥,如图: 2.点击创建公钥,弹出选项点下一步 3.继续点下一步: 4.继续点下一步: 5.继续点下一步(密钥长度默认1024即可),生成密钥需 ...

  9. REST framework---基于类的视图

    一.程序设计 1.路由设计 from django.conf.urls import url from django.contrib import admin from app import view ...

  10. MOS管的低端驱动和高端驱动

    低端功率开关驱动电路的工作原理 低端功率开关驱动的原理非常简单,就是负载一端直接和电源正端相连,另外一端直接和开关管相连,正常情况下,没有控制信号的时候,开关管不导通,负载中没有电流流过,即负载处于断 ...