#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 mod,int st,int limit)//pos为数位从高位开始枚举(达到上限再枚举下一位),mod为对13求余,初始为0,st为状态,初始为0,limit为是否达到上限,1达到上限,0没有达到上限继续枚举
{
if(pos<)
return mod==&&st==;
if(!limit&&dp[pos][mod][st]!=-)
return dp[pos][mod][st];
int len=limit?num[pos]:;//判断上一位是否到上限,若达到则只能枚举到num【pos】,否则可以枚举0——9
int modx,stx;
LL ans=;
for(int i=;i<=len;i++)
{
modx=(mod*+i)%;
stx=st;
if(st==&&i!=)
stx=;
if(st==&&i==)
stx=;
if(st==&&i==)
stx=;
ans+=dfs(pos-,modx,stx,limit&&i==len);
}
if(!limit)//没有达到上限的都要存储一下该状态下的符合条件数;
dp[pos][mod][st]=ans;
return ans; }
LL sv(LL a)
{
int len=;
memset(dp,-,sizeof(dp));
memset(num,-,sizeof(num));
while(a)
{
num[len++]=a%;
a/=;
}
dfs(len-,,,);
}
int main()
{
LL n;
while(~scanf("%lld",&n))
{
LL ee=sv(n);
printf("%lld\n",ee);
}
}

HDU - 3652的更多相关文章

  1. 数位DP入门之hdu 3652 B-number

    hdu 3652 B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer ...

  2. 【HDU 3652】 B-number (数位DP)

    B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer whose de ...

  3. Hdu 3652 B-number (同余数位DP)

    题目链接: Hdu 3652 B-number 题目描述: 给出一个数n,问 [1, n]区间内有几个数能被13整除并且还有13这个子串? 解题思路: 能整除的数位DP,确定好状态随便搞搞就能过了.d ...

  4. hdu 3652 【数位dp】

    hdu 3652 题意:求1到n中包含'13'('13'不一定连续)且能被13整除的数的个数. 这是我第一道比较了能看懂的数位dp.定义状态dp[pos][res][sta]表示处理到第pos位,模的 ...

  5. HDU 3652:B-number(数位DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=3652 题意:求数位含有13和可以被13整除的数字个数. 思路:记录3种状态: st == 0 表示 从最高位到第 ...

  6. hdu 3652 B-number(数字dp)

    http://acm.hdu.edu.cn/showproblem.php? pid=3652 大致题意:"B-number"即一个整数含有子串"13"且被13 ...

  7. HDU - 3652 数位DP 套路题

    题意:统计能被13整除和含有13的数的个数 解法没法好说的..学了前面两道直接啪出来了 PS.HDU深夜日常维护,没法交题,拿网上的代码随便对拍一下,输出一致 #include<bits/std ...

  8. HDU 3652 B-number(数位DP)

    题目链接 学习大神的数位DP模版. #include <iostream> #include <cstdio> #include <cstring> using n ...

  9. HDU 3652 B-number

    也是数位dp.考虑反面会简单很多. #include<iostream> #include<cstdio> #include<cstring> #include&l ...

  10. HDU 3652 B-number(数位dp)

    题意:B数的定义是有字符串“13”且能被整数13整除的数,求[1,n]内的B数个数. 题解:这是数位DP,我也就是刚入门,前两天看到了非递归写法,好麻烦.所以我建议写dfs的方法,容易理解,代码还简短 ...

随机推荐

  1. sql for xml path用法

    一.FOR XML PATH 简单介绍              那么还是首先来介绍一下FOR XML PATH ,假设现在有一张兴趣爱好表(hobby)用来存放兴趣爱好,表结构如下: 接下来我们来看 ...

  2. python 选课系统

    couser.py: import sys,osBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.pa ...

  3. xamarin.Android开发前的配置

    vs2019开发 入门教程 https://docs.microsoft.com/zh-cn/xamarin/android/get-started/installation/android-emul ...

  4. js某一元素在数组中的索引

    第一种:数组遍历 function search(arr,dst){ var i = arr.length; while(i-=1){ if (arr[i] == dst){ return i; } ...

  5. PostgreSQL 9.5.x的架构图及外存图

  6. 第一次安装myeclipse+tomcat经验

    在网上找了很多资料,这里记录一下验证有用的资料,避免以后走弯路 1.安装myeclipse 参考如下URL,亲测有用 https://blog.csdn.net/qingjianduoyun/arti ...

  7. 学Python的感受

    这门课程已经上了两周了,虽然还没学到什么实质上的东西,只是做了几道题,但是我也感受到了Python的魅力.我感觉这门课真的很有用,比如老师所说的网络爬虫,我对这个非常感兴趣.再说说老师的教学方式,理论 ...

  8. LapSRN

    Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution 解决问题: 1.bicubic预处理上下采样,计算复杂度高 ...

  9. Linux基础命令---iostat显示设备状态

    iostat iostat指令用来显示cpu状态,系统IO设备的状态,以及相关磁盘和NFS使用状态.iostat命令通过观察设备相对于其平均传输速率的活动时间来监视系统输入/输出设备负载.iostat ...

  10. sql语句中select……as的用法