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 ...
随机推荐
- grep中正则匹配的使用
如要匹配Computer或computer两个单词,可做如下操作: [Cc]mputer “.”允许匹配ASCII集中任意字符,或为字母,或为数字. 使用\{\}匹配模式结果出现的次数 匹配字母A出现 ...
- Java集合---HashMap源码剖析
一.HashMap概述二.HashMap的数据结构三.HashMap源码分析 1.关键属性 2.构造方法 3.存储数据 4.调整大小 5.数据读取 ...
- Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode ri ...
- spring与redis简单整合
项目结构 整合需要的依赖 <dependencies> <dependency> <groupId>org.springframework</groupId& ...
- Rsyslog配置文件详解
Rsyslog配置文件详解https://my.oschina.net/0757/blog/198329 # Save boot messages also to boot.log 启动的相关信息lo ...
- 去bom头
function rewrite ($filename, $data) { $filenum = fopen($filename, "w"); flock($filenum, LO ...
- OnScrollListener回调分析
new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView ...
- 记一次奇怪IE动态加载js的乱码
1. 问题背景 某个老产品需要支持IE8,前端部分组件采用scrat开发体系进行开发的,当页面中内嵌的iframe的页面再加载组件js的时候,某些情况下会出现组件的js乱码,导致组件的js不能运行.而 ...
- 必须使用"角色管理工具"安装或配置microsoft.net framework 3.5
windows 2008 R2 安装.net framework 3.5报错 : 解决方法: (1)打开服务器管理器 (2)右击左侧功能——>添加功能 (3)向导中勾选.NET Framewor ...
- Netty之有效规避内存泄漏
有过痛苦的经历,特别能写出深刻的文章 —— 凯尔文. 肖 直接内存是IO框架的绝配,但直接内存的分配销毁不易,所以使用内存池能大幅提高性能,也告别了频繁的GC.但,要重新培养被Java的自动垃圾回收惯 ...