题意:给出n,问1-n中有13且能整除13的数数量。

就是hd3555和codeforces beautiful number的合成版。dp记录待填长度,是否带有13,前面数的模13余数,前一个数是k的时候的b-number数数量。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
const double EPS=1e-;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon;
int dp[][][][]; int dfs(int pos,int sum,int pre,int limit,string &str,int inc)
{
if(pos==str.size())return inc&&(sum%==);
if(!limit&&dp[str.size()-pos-][sum][pre][inc]!=-)return dp[str.size()-pos-][sum][pre][inc];
int up=limit?str[pos]-'':;
int res=;
for(int i=;i<=up;++i)
{
int nexsum=(sum*+i)%;
if(pre==&&i==)res+=dfs(pos+,nexsum,i,limit&&i==str[pos]-'',str,);
else res+=dfs(pos+,nexsum,i,limit&&i==str[pos]-'',str,inc);
//if(pos==1&&pre==1)cout<<i<<" "<<res<<" "<<endl;
}
if(!limit)dp[str.size()-pos-][sum][pre][inc]=res;
return res;
} int work(string &str)
{
return dfs(,,,,str,);
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
//lon casenum;
//cin>>casenum;
memset(dp,-,sizeof(dp));
//for(lon time=1;time<=casenum;++time)
string str;
for(lon time=;cin>>str;++time)
{
cout<<work(str)<<endl;
}
return ;
}

hdoj3652 B-number的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [LeetCode] Number of Segments in a String 字符串中的分段数量

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

随机推荐

  1. Python: dict setdault函数与collections.defaultdict()的区别

    setdault用法 >>>dd={'hy':1,'hx':2} >>>cc=dd.setdefault('hz',1) >>>cc      返 ...

  2. ES6学习笔记之map、set与数组、对象的对比

    ES6 ES5中的数据结构,主要是用Array和Object.在ES6中主要新增了Set和Map数据结构.到目前为止,常用的数据结构有四种Array.Object.Set.Map.下面话不多说了,来一 ...

  3. OpenCV-跟我一起学数字图像处理之拉普拉斯算子

    https://www.cnblogs.com/german-iris/p/4840647.html Laplace算子和Sobel算子一样,属于空间锐化滤波操作.起本质与前面的Spatial Fil ...

  4. 关于linux中的上下文切换

    对于linux中的上下文一直以来没有特别的关注其合理范围应该是多少(关于上下文切换的概念,网上已经有很多解释了,再次不再重复),白天偶尔注意到了一下,晚上特地看了下白天负载和和收盘后的负载如下(服务器 ...

  5. 通过一个例子了解Ajax

    Ajax指的Asyncronous JavaScript and XML Ajax并不是什么新的编程语言, 它是现有一些东西的应用.从它的名称中就可以看出来 假如我们设想, 浏览器展示了一个页面,但需 ...

  6. nw.exe开发DEMO下载

    参考的原文链接:http://www.jianshu.com/p/7c66ee28ce51 最后,开发者怕你怀疑nw.js的强大,又提供了几个Demo和许多成功的案例来打消我们的顾虑.

  7. 20145206邹京儒 EXP7网络欺诈技术防范

    20145206邹京儒 EXP7网络欺诈技术防范 一.实践过程记录 URL攻击实验前准备 1.在终端中输入命令:netstat -tupln |grep 80,查看80端口是否被占用,如下图所示 2. ...

  8. 2017.11.11 B201 练习题思路及解题方法

    2017.11.11 B201 练习题思路及解题方法 题目类型及涵盖知识点 本次总共有6道题目,都属于MISC分类的题目,涵盖的知识点有 信息隐藏 暴力破解 音轨,摩斯电码 gif修改,base64原 ...

  9. 20145333茹翔 Exp5 Adobe阅读器漏洞攻击

    20145333茹翔 Exp5 Adobe阅读器漏洞攻击 实验过程 主机为kali的ip地址为:192.168.1.111.靶机windows xp 的ip地址为:192.168.1.110 使用命令 ...

  10. 【入门详解】MyBatis入门基础详解

    什么是mybatis? MyBatis是支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索.MyBatis使用简单的XM ...