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. javascript提高篇+吐槽

    开篇吐槽 最近一直在投简历找工作,对于博主这样的屌丝应届生来说,一没过硬的技术,二没经验,三没高学历,四没炫酷的项目,五还没漂亮的简历,简直就是3无产品+2b青年.所以快1个月了投的简历没有收到一个面 ...

  2. Mybatis学习笔记(二) 之实现数据库的增删改查

    开发环境搭建 mybatis 的开发环境搭建,选择: eclipse j2ee 版本,mysql 5.1 ,jdk 1.7,mybatis3.2.0.jar包.这些软件工具均可以到各自的官方网站上下载 ...

  3. C#中的系统时间获取问题

    C#获取当前系统时间 2010-01-02 16:24 --DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 取当前年月日 ...

  4. OBIEE接受外部参数

    样例: http://192.168.0.99/analytics/saw.dll?Go&Path=/shared/goxiangyibiaopan/SBDW_GSYDL_ZZT&Ac ...

  5. [Jenkins]admin用户登陆,提示登陆无效(之前登陆OK,三天没有登陆,突然提示登陆无效,重启无法解决)的解决方法

    问题出现现象: 系统一直正常,突然某天登陆,提示用户无效,无法登陆成功. 问题分析过程: 1.查看日志:/var/log/jenkins/jenkins.log(通过ps -elf | grep je ...

  6. [学习笔记]agileone安装登陆报错,localhost重定向次数过多

    1.找到.htaccess文件 2.修改RewriteEngine  参数为off即可

  7. phonegap 随笔

    开发者论坛 http://bbs.phonegapcn.com/forum.php phone调用android本地方法 http://blog.csdn.net/crazyman2010/artic ...

  8. Android中设定EditText的输入长度

    方法一:可以在layout xml中加上属性android:maxLength 比如: <EditText         android:id="@+id/editTextShow& ...

  9. 关于sbutils中的sblaunch插件的疑惑

    一.sbutils介绍 sbutils是一个开源的越狱手机基础功能的插件包,其中包含sblaunch这个启动插件,该插件可以实现命令行下面打开app并传递一个url. sbutils下载地址:http ...

  10. 第八章 监控 Zabbix

    1.1   YUM部署 Zabbix 2.4 1.  前期准备(省略) l   Yum源的配置 cd /etc/yum.repos.d/; mkdir old;mv ./* old/ rpm -Uvh ...