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 ...
随机推荐
- java IO 学习总结
推荐文章:java I/O学习 只要是处理纯文本数据,就要优先考虑使用字符流,除此之外都用字节流 字符流:FileReader和BufferedReader的使用 String path = &quo ...
- java 求 两个数的百分比% (转)
int num1 = 7; int num2 = 9; // 创建一个数值格式化对象 NumberFormat numberFormat = NumberFormat.getInstance(); / ...
- Git 实战教程
CVS及SVN都是集中式的版本控制系统,而Git是分布式版本控制系统,集中式和分布式版本控制系统有什么区别呢? 先说集中式版本控制系统,版本库是集中存放在中央服务器的,而大家工作的时候,用的都是自己的 ...
- jQuery DOM 与 原生DOM 互相转换的方法
jQuery 转 js $('#element').get(0); // 等于 document.getElementById('element'); // 输出 <p id="ele ...
- WebService 学习
WebService是一种跨编程语言和跨操作系统平台的远程调用技术. XML+XSD, SOAP 和 WSDL 是构成WebService平台的三大技术. SOAP = HTTP协议 + XML数据格 ...
- Python开发【第三章】:Python的文件操作
一.文件操作模式概述 1.打开文件的模式: r, 只读模式[默认] w,只写模式[不可读:不存在则创建:存在则删除内容:] a, 追加模式[不可读:不存在则创建:存在则只追加内容:] 2." ...
- ROW_NUMBER
16:23 2015/4/16 删除重复数据,连续被两位同事问到完全相同的重复记录如何删除只保留一条 create table del_samerecords (id )) go insert int ...
- selected对话框全选
selected对话框全选 <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- xavante运行cgilua流程
安装软件 需要安装三个lua 库: xavante wsapi cgilua luarocks install xavante http://keplerproject.github.io/xava ...
- 使用MapReduce实现一些经典的案例
在工作中,很多时候都是用hive或pig来自动化执行mr统计,但是我们不能忘记原始的mr.本文记录了一些通过mr来完成的经典的案例,有倒排索引.数据去重等,需要掌握. 一.使用mapreduce实现倒 ...