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. 标签<a>的注意事项1

    使用a标签时,其子元素可以为其他元素,但是不能包含<a>标签,否则会造成布局改变! 因此请尽量不要在a标签里放太多子元素,可以在外层套一个div,其他子元素放在a标签同级下. 正确布局: ...

  2. C#23种开发模式,陆续完善中

    #region 单例模式 #region 线程非安全单例模式 public class Singleton1 { private Singleton1() { } private static Sin ...

  3. Winsock - 1 - Winsock API

    Winsock Winsock API Winsock是网络编程接口,而不是协议. 网络原理和协议 建立Winsock规范的主要目的是提供一个与协议无关的传送接口. Winsock将网络编程接口与具体 ...

  4. jquery插件autoComplete自动弹出

    导入 <link rel="stylesheet" href="${ctx }/static/plugins/jQuery-autoComplete-master/ ...

  5. 在http编程的门口----飞牛网自动下单,查单

    刚进这个公司,以前没接触过http编程,所以这两天做了个小例子来熟悉http编程,有点晕..... 不过还是做出来了,虽然有点粗糙,总结一下这个小软件: 主要使用QNetworkAccessManag ...

  6. SIGPIPE信号

    #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include &l ...

  7. python绝技 — 用Scapy解析TTL字段的值

    #!/usr/bin/env python #--*--coding=utf-8--*-- #打印收到的数据包的源IP和TTL值 from scapy.all import * def testTTL ...

  8. 2-Bom

    前言 window对象是BOM的顶层(核心)对象,所有对象都是通过它延伸出来的,也可以称为window的子对象.由于window是顶层对象,因此调用它的子对象时可以不显示的指明window对象 例如下 ...

  9. [SQL基础教程] 3-2 对表进行分组

    [SQL基础教程] 3-2 对表进行分组 GROUP BY SELECT <列名1>,<列名2>,... FROM <表名> GROUP BY <列名1> ...

  10. ECOS-Ecstore证书生产失效问题排查

    无法生成证书问题排查 无法生成证书问题排查 author :James,jimingsong@vip.qq.com since :2015-03-02 名称解释(官方) 常见错误 1. 名称解释(官方 ...