hdu3652B-number(数位dp)
B-number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6444 Accepted Submission(s):
3739
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.
integer n(1 <= n <= 1000000000).
100
200
1000
1
2
2
题意:找出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)的更多相关文章
- 多校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 用作标记,当现在枚举的数小 ...
- hdu 5898 odd-even number 数位DP
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...
- codeforces Hill Number 数位dp
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits: 5000 MS Memory Limits: ...
- 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 ...
- Fzu2109 Mountain Number 数位dp
Accept: 189 Submit: 461Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description One ...
- HDU 3709 Balanced Number (数位DP)
Balanced Number Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) ...
- beautiful number 数位DP codeforces 55D
题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...
- FZU - 2109 Mountain Number 数位dp
Mountain Number One integer number x is called "Mountain Number" if: (1) x>0 and x is a ...
- 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 ...
- 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 ...
随机推荐
- 回顾Google IO 2016 -Keynote【图解】
Google IO大会倒计时进行中~~ 两名演奏者在使用高空“古筝”. 最后5秒倒计时~~~~全场轰动~ 倒计时结束,IO大会正式开始.屏幕中,一个人把纯白的唱片放入唱片机中. 然后欢快的音乐响起,台 ...
- PHP 之用证书对数据进行签名、验签、加密、解密
/** * 对数据进行签名 * $data = 'If you are still new to things, we’ve provided a few walkthroughs to get yo ...
- P2746 [USACO5.3]校园网Network of Schools// POJ1236: Network of Schools
P2746 [USACO5.3]校园网Network of Schools// POJ1236: Network of Schools 题目描述 一些学校连入一个电脑网络.那些学校已订立了协议:每个学 ...
- MySQL中的分页操作结合python
mysql中的分页操作结合python --分页: --方式1: ;-- 读取十行 , --从第十行读取 往后再读十行 --方式2: offset ; --从第二十行开始读取10行 -- 结合pyth ...
- 03.requests模块(1)
目录 03.requests模块(1) 展开requests模块的学习 代码实例 需求:爬取搜狗指定词条搜索后的页面数据 需求:登录豆瓣电影,爬取登录成功后的页面数据 需求:爬取豆瓣电影分类排行榜 h ...
- PAT 1102 Invert a Binary Tree
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote ( ...
- mysql参数设置与查看
查看默认的参数设置(包含读取到的参数文件中的设置) mysqld --verbose --help 查看默认的参数设置(不包含参数文件中的设置) mysqld --no-defaults --ve ...
- HBase行键的设计
rowkey是行的主键,而且hbase只能用rowkey范围即scan来查找数据.rowkey是以字典排序的.可以巧妙设计行键,比如想通过电影的评价进行排序,可以把评分rate和电影id组合起来,ra ...
- CODEVS——T 2969 角谷猜想
http://codevs.cn/problem/2969/ 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Descri ...
- fork me on github 彩带设置无效
挑选彩带地址: https://github.com/blog/273-github-ribbons 发现代码复制粘贴过来,但是在自己博客园上无效,如粘贴如下代码 <a href="h ...