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. win10的IIS配置

    安装IIS: 控制面板---程序---启用或关闭windows功能---Internet Information Services IIS  和 IIS 可承载的web核心 有何区别?  是否两个都必 ...

  2. idea导入web项目的部署

    前几天 参考 http://zyjustin9.iteye.com/blog/2172712 这篇文章的部署,一直没有问题,今天又部署了一个项目,按照这个步骤,死活却不能部署成功.最后发现,原来是在部 ...

  3. CodeForces 645B Mischievous Mess Makers

    简单题. 第一次交换$1$和$n$,第二次交换$2$和$n-1$,第三次交换$3$和$n-2$.....计算一下就可以了. #pragma comment(linker, "/STACK:1 ...

  4. PostgreSQL 序列使用

    数据库中主键的生成一般是通过序列来生成,PG的序列知识主要罗列如下: 如何找到序列的名称:用pgadmin打开当前所用数据库,在schemas->sequences下找到相关的序列,然后SELE ...

  5. -webkit-tap-highlight-color处理元素点击默认高亮

    -webkit-tap-highlight-color:transparent; 或者 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

  6. SDN基础

    http://www.h3c.com.cn/Solution/Smart_Network/SDN/ http://network.51cto.com/network/content2013/SDNke ...

  7. 关于64位win7环境下VS连接oracle数据库的问题

    本机环境:64位win7,安装了64位的oracle桌面类 服务器环境:64位windows server 2008,64位oracle服务器端 问题:本机用sql developer连数据库没有问题 ...

  8. Lintcode解题报告

    1. Num.196 寻找缺失的数 给出一个包含 0 .. N 中 N 个数的序列,找出0 .. N 中没有出现在序列中的那个数. 注意事项 可以改变序列中数的位置. 您在真实的面试中是否遇到过这个题 ...

  9. Linux下的数据监控工具

    Vmstat Vmstat,virtual memmory statistics(虚拟内存统计),主要是对操作系统的内存信息.进程状态.cpu活动等进行监视,但是它不能对某个进程进行深入的分析. Pr ...

  10. PHP基础语法思维导图