B-number

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3652

数位dp

这题是暑期集训的时候做的,昨天补了数位dp的记忆化搜索做法,把艾神的递推算法更新一下。

代码如下:

 #include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#define LL long long
#define LEN 20
#define is_1 2
#define have_13 2
#define mod_by_13 13
#define pre_same 2
using namespace std;
LL t[LEN];
LL dp[LEN][is_1][have_13][mod_by_13][pre_same];
string s;
LL len;
void init_t();
void solve();
int main(void){
init_t();
while(cin>>s){
len=s.size();
memset(dp,,sizeof(dp));
dp[][][][][]=;
solve();
LL temp=;
for(int i=;i<is_1;++i)
for(int j=;j<pre_same;++j)
temp+=dp[len][i][][][j];
cout<<temp<<endl;
}
}
void init_t(){
t[]=;
for(int i=;i<LEN;++i)
t[i]=(t[i-]*)%;
}
void solve(){
for(int a=;a<len;++a)
for(int b=;b<is_1;++b)
for(int c=;c<have_13;++c)
for(int d=;d<mod_by_13;++d)
for(int e=;e<pre_same;++e)
if(dp[a][b][c][d][e]){
int r=(e?s[a]-'':);
for(int x=;x<=r;++x){
dp[a+][x==][c|(b&&x==)][(d+t[len-a-]*x)%][e&&x==r]
+=dp[a][b][c][d][e];
}
}
}

感觉还是太懒了,这两周金工实习这么好的机会,居然每天也只能写一道题,而且是水题。

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. Linux界面自动化测试框架不完全汇总

    首先可参考wiki此文,非常详尽:https://en.wikipedia.org/wiki/List_of_GUI_testing_tools 以下是我调研并实验过的(实验环境ubuntu 16.0 ...

  2. Normalize.css 样式作用,及使用方法

    Normalize.css 是? Normalize.css 是一个可以定制的CSS文件,它让不同的浏览器在渲染网页元素的时候形式更统一. Normalize.css 能干什么? 保留有用的默认值,不 ...

  3. 关于web多标签多条件筛选的思考以及缓存的正确使用方法(上)

    做项目的过程中,发现一次远程链接数据库的耗时大概是300ms~400ms,切身体会到了前辈们经常说的减少链接的重要性,用了缓存后页面的打开时间从1.5s减少到400ms 前提: 那么来说一说正题,we ...

  4. nodeValue、firstChild和lastChild属性

    nodeValue属性如果想改变一个文本节点的值,那就使用DOM提供的nodeValue属性,他用来得到(和设置)一个节点的值:node.nodeValue但是有个细节必须注意:在用nodeValue ...

  5. mysql添加为成绩表添加名次

    对于一种这样的表,为score添加名次

  6. java 文件下载支持中文名称

    /** * 文件下载 * @param filePath 文件路径 * @param fileName 文件名称 */ public void download(String filePath,Str ...

  7. git忽略某些文件提交

    git忽略某些文件提交   在项目中有些配置文件不需要提交,但是有同学在后面开发中发现在.igonore文件中无论如何都无法忽略某些文件的提交.原因在这里: 已经维护起来的文件,即使加上了gitign ...

  8. ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE

    ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE 打开 /app/base/lib/application/dbtable.php , 替换A ...

  9. java-进程

    一个java进程,只有一个入口,就是main方法. tomcat是一个java进程,tomcat只有一个入口,org.apache.catalina.startup.Bootstrap  类的main ...

  10. Vrui 增加自定义事件

    #include <Vrui/Application.h> #include <GL/GLObject.h> #include <Vrui/Vrui.h> #inc ...