hdu3652 B-number
题意求能够整除和包含13的数字。
这个比较简单,保留余数及1,然后标记前面是否出现过13就行。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL n,dp[][][][];
int d[];
LL dfs(int i,bool e,int r,bool o,bool p)
{
if(i==-)
{
return r==&&p;
}
if(!e&&dp[i][r][o][p]!=-)
return dp[i][r][o][p];
int j;
int mk = e?d[i]:;
LL ans = ;
for(j = ; j <= mk ; j++)
{
if(p)
ans+=dfs(i-,e&&j==mk,(r*+j)%,,);
else
{
if(o&&j==)
ans+=dfs(i-,e&&j==mk,(r*+j)%,,);
else if(j==)
ans+=dfs(i-,e&&j==mk,(r*+j)%,,);
else
ans+=dfs(i-,e&&j==mk,(r*+j)%,,);
}
}
return e?ans:dp[i][r][o][p]=ans;
}
LL cal(LL x)
{
int g=;
while(x)
{
d[g++] = x%;
x/=;
}
return dfs(g-,,,,);
}
int main()
{
memset(dp,-,sizeof(dp));
while(cin>>n)
{
cout<<cal(n)<<endl;
}
return ;
}
hdu3652 B-number的更多相关文章
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
- Harmonic Number(调和级数+欧拉常数)
题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- 移除HTML5 input在type="number"时的上下小箭头
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...
- 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.免费应用程序调试最 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...
- [LeetCode] Number of Boomerangs 回旋镖的数量
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...
- [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 ...
随机推荐
- 以Debug模式启动JBoss
JBoss服务器的启动方法: 假设JBoss的安装目录为$JBOSS_HOME,Windows以及Linux环境下的Debug模式的启动方法分别为:Windows环境:找到Windows下的JBoss ...
- stty--设置终端线
stty - chang and print terminal line settings SYNOPSIS stty [-F DEVICE | --file=DEVICE] [SETTING]... ...
- des加密解密的两个方法
<?php //$input - stuff to decrypt //$key - the secret key to use function do_mencrypt($input, $ke ...
- JS的URL编码
背景 URL只能使用英文字母.阿拉伯数字和某些标点符号,不能使用其他文字和符号,这是网络标准: 只有字母和数字[-9a-zA-Z].一些特殊符号"$-_.+!*'(),"[不包括双 ...
- PHP中fopen,file_get_contents,curl函数的区别
PHP中fopen,file_get_contents,curl函数的区别 1.fopen/file_get_contents每次请求都做DNS查询,并不对DNS的信息进行缓存,而curl会对DNS的 ...
- 2016年4月1日下午,《java入门123》翻开了第一页,从此走上不归路。新手初来乍到,献上见面礼
package copyfile; import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream ...
- 芯航线FPGA学习套件之4*4矩阵键盘模块测试手册
芯航线FPGA学习套件之4*4矩阵键盘模块测试手册 本手册以简明扼要的方式介绍芯航线FPGA学习套件提供的矩阵键盘模块的测试方法: 连接开发板,如下所示: 2.将矩阵键盘模块与开发板按如下图所 ...
- [转]Setup-Subversion-1.6.5+TortoiseSVN-v1.6.5
转载地址:http://xietingfengsxm.blog.163.com/blog/static/994118512010729111624385/ 开发环境: myEclipse6.5+ecl ...
- 一段处理百分数的js代码
function percent(s, e, i){ s = Number(s), isNaN(s) && (s = "0"); var n = "%&q ...
- MYSQL #1064错误
你的给出的代码里option为MYSQL关键字,不能直接写,需要用`包括起来(它为数字键1左边的键上的字符),为: `option` varchar(50) NOT NULL default ''