题意:给出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 循环队列的实现

    最近在做一个东西的时候发现需要用到循环队列,实现先进先出(FIFO),不断往里面添加数据,当达到某个限定值时,最先进去的出去,然后再添加.之后需要对队列里面的内容进行一个筛选,作其他处理.首先我想到了 ...

  2. Linux虚拟机克隆后网卡UUID问题

    虚拟机中的Linux系统克隆后,网卡配置eth0中的UUID可被克隆的系统是一样的,这样UUID就失去了唯一性. 我参考了该篇博客: 有时我们不小心将/etc/sysconfig/network-sc ...

  3. python 运行脚本报错 from keyword import iskeyword as _iskeyword ImportError: cannot import name iskeyword,说明python环境坏了,得重装,尚不知具体原因,

    C:\Python27\Scripts>python task_test.pyTraceback (most recent call last):  File "task_test.p ...

  4. VNC的安装和常用命令

    主要参考文章:http://www.cnblogs.com/coderzh/archive/2008/07/16/1243990.html                         http:/ ...

  5. python3.4学习笔记(十) 常用操作符,条件分支和循环实例

    python3.4学习笔记(十) 常用操作符,条件分支和循环实例 #Pyhon常用操作符 c = d = 10 d /= 8 #3.x真正的除法 print(d) #1.25 c //= 8 #用两个 ...

  6. 【运维技术】Nexus私服安装配置常用问题

    maven私服安装配置 软件安装及基本配置 安装配置 # 安装jdk,参考其他教程 mkdir -p /app/nexus2 # 创建目录 wget https://download.sonatype ...

  7. 20145206邹京儒 web安全基础实践

    20145206邹京儒 web安全基础实践 一.实践过程记录 关于WebGoat 1.我们在命令行里执行:java -jar webgoat-container-7.0.1-war-exec.jar运 ...

  8. 20145319 《网络渗透》web安全基础实践

    20145319 <网络渗透>web安全基础实践 问题回答 Sql注入攻击原理,如何防御 攻击原理:由于对于用户输入并没做出相应限制,因此可以通过构造特定的sql语句,达到自身的一些非法目 ...

  9. Visual Status各个版本官网下载

    网址:https://www.visualstudio.com/zh-hans/vs/older-downloads/

  10. Android灯光系统--通知灯深入分析

    Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 getSystemService(获得通知服务) 构造notification 类别 其他参数(颜色, ...