zoukankan      html  css  js  c++  java
  • How Many Zeroes? LightOJ

    #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[55][55],num[55];
    LL dfs(int pos,int iszero,int st,int limit)//pow为数位,iszero判断是否为0,st上一个状态初始为0,limit是否达到上限
    {
        if(pos<0)
        {
            if(iszero)
                return 1;
            else
                return st;
        }
        if(!limit&&!iszero&&dp[pos][st]!=-1)
            return dp[pos][st];
        LL ans=0;
        int len=limit?num[pos]:9;
        for(int i=0;i<=len;i++)
        {
            if(iszero)
                ans+=dfs(pos-1,i==0,0,limit&&i==len);
            else
                ans+=dfs(pos-1,0,st+(i==0),limit&&i==len);
        }
        if(!limit&&!iszero)
            dp[pos][st]=ans;
        return ans;
    
    }
    LL sv(LL a)
    {
        int len=0;
        memset(dp,-1,sizeof(dp));
        memset(num,0,sizeof(num));
        while(a)
        {
            num[len++]=a%10;
            a/=10;
        }
        return dfs(len-1,1,0,1);
    }
    int main()
    {
        LL m,n;
        while(~scanf("%lld%lld",&n,&m))
        {
          //  LL ee=sv(m)-sv(n-1);
            printf("%lld
    ",sv(m)-sv(n-1));
        }
    
    }
  • 相关阅读:
    大数据概述
    语法分析-代码
    语法分析-C语言程序
    Hadoop综合大作业
    hive基本操作与应用
    理解MapReduce计算构架
    熟悉HBase基本操作
    爬虫大作业
    熟悉常用的HDFS操作
    数据结构化与保存
  • 原文地址:https://www.cnblogs.com/nr1999/p/9401938.html
Copyright © 2011-2022 走看看