B-number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6444    Accepted Submission(s):
3739

Problem Description
A wqb-number, or B-number for short, is a non-negative
integer whose decimal form contains the sub- string "13" and can be divided by
13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your
task is to calculate how many wqb-numbers from 1 to n for a given integer
n.
 
Input
Process till EOF. In each line, there is one positive
integer n(1 <= n <= 1000000000).
 
Output
Print each answer in a single line.
 
Sample Input
13
100
200
1000
 
Sample Output
1
1
2
2
 
Author
wqb0039
 
Source
 
 
 

题意:找出1~n范围内含有13并且能被13整除的数字的个数

思路:http://blog.csdn.net/libin56842/article/details/10026063

#include<cstdio>
#include<iostream>
#include<cstring> using namespace std;
int dit[],f[][][]; int dfs(int pos,int mod,int have,int lim)
{
int num,ans,mod_x,have_x;
if(pos<=) return mod== && have==;
if(!lim && f[pos][mod][have]!=-) return f[pos][mod][have];
num=lim?dit[pos]:;ans=;
for(int i=;i<=num;i++)
{
mod_x=(mod*+i)%; have_x=have;
if(have== && i==) have_x=;
if(have== && i!=) have_x=;
if(have== && i==) have_x=;
ans+=dfs(pos-,mod_x,have_x,lim&&i==num);
}
if(!lim) f[pos][mod][have]=ans;
return ans;
} int main()
{
int n,len;
while(~scanf("%d",&n))
{
memset(dit,,sizeof dit);
memset(f,-,sizeof f);len=;
while(n)
{
dit[++len]=n%;
n/=;
}dit[len+]=;
printf("%d\n",dfs(len,,,));
}
return ;
}
 

hdu3652B-number(数位dp)的更多相关文章

  1. 多校5 HDU5787 K-wolf Number 数位DP

    // 多校5 HDU5787 K-wolf Number 数位DP // dp[pos][a][b][c][d][f] 当前在pos,前四个数分别是a b c d // f 用作标记,当现在枚举的数小 ...

  2. hdu 5898 odd-even number 数位DP

    传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...

  3. codeforces Hill Number 数位dp

    http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits: ...

  4. HDU 5787 K-wolf Number 数位DP

    K-wolf Number Problem Description   Alice thinks an integer x is a K-wolf number, if every K adjacen ...

  5. Fzu2109 Mountain Number 数位dp

    Accept: 189    Submit: 461Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description One ...

  6. HDU 3709 Balanced Number (数位DP)

    Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  7. beautiful number 数位DP codeforces 55D

    题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...

  8. FZU - 2109 Mountain Number 数位dp

    Mountain Number One integer number x is called "Mountain Number" if: (1) x>0 and x is a ...

  9. BNU 13024 . Fi Binary Number 数位dp/fibonacci数列

    B. Fi Binary Number     A Fi-binary number is a number that contains only 0 and 1. It does not conta ...

  10. hdu 5898 odd-even number(数位dp)

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

随机推荐

  1. Python_多线程1(创建线程,简单线程同步)

    threading 模块除了包含 _thread 模块中的所有方法外,还提供的其他方法: threading.currentThread(): 返回当前的线程变量. threading.enumera ...

  2. js的hex转base64

    if (!window.atob) { var tableStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 ...

  3. @viewChild

    https://www.cnblogs.com/mttcug/p/8004359.html

  4. [forward]警惕UNIX下的LD_PRELOAD环境变量

    From: https://blog.csdn.net/haoel/article/details/1602108 警惕UNIX下的LD_PRELOAD环境变量 前言 也许这个话题并不新鲜,因为LD_ ...

  5. js的StringBuffer类

    function StringBuffer(str){ var arr = []; str = str || ""; arr.push(str); this.append = fu ...

  6. win10如何进入安全模式的几种方法

    首先,说一下安全模式的作用: 安全模式, 用途有很多,常见的作用有以下几点 1. 电脑可能由于安装了某些驱动或者软件,不兼容导致电脑启动不了,可以进入安全模式卸载 2. 电脑中病毒之后,可以进入安全模 ...

  7. Python 爬虫之第一次接触

    爬豆瓣网电影TOP250名单 ------- 代码未写完,等待更新 import requests from requests.exceptions import RequestException i ...

  8. Python - 模块(一)

    目录 Python - 模块(一) 模块的引用方式 常用模块 random(随机模块) os模块 sys 序列化模块 hashlib subprocess optparse struct Python ...

  9. [luoguP2870] [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold(后缀数组)

    传送门 数据小的话贪心就行. 可以把这个串翻转再接到后面,再求后缀数组,求出 rank 数组就很简单了. ——代码 #include <cstdio> #include <iostr ...

  10. nyoj 307

    /*这是一道最短路变形题 从每个有藏宝的地方为起点 求到各个点的可以的最大重量,相当于求出了从出口 到 一个藏宝点 所  允许的最大重量,把所有藏宝点的按重量 排序(从小到大)先到最小的藏宝点带上 宝 ...