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 ...
随机推荐
- EntityFramework SQLiteCodeFirst 自动创建数据库 关闭级联删除
外键的级联删除: 如A表中有主键idA, B表中设置外键(ForeignKey)为A表中的主键idA, 当A表中的记录被删除时, B表中所有引用此条记录的记录(即所有外键为idA的记录)将自动被删除 ...
- Spark运行原理解析
前言: Spark Application的运行架构由两部分组成:driver program(SparkContext)和executor.Spark Application一般都是在集群中运行,比 ...
- C#使用ajaxForm进行上传图片
<div class='imgOuter addImgBtn l_canshu' id='ImagePath1' value=''> <img src="../Images ...
- Mac OS 电脑播放 iPhone音乐
http://apple.stackexchange.com/questions/6173/can-i-play-audio-from-my-iphone-on-my-mac Simple, and ...
- lleetcode 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...
- select2插件的使用
<select id="prd_tech_for_load" class="selectable" style="width:180px;&qu ...
- RDIFramework.NET V2.8版本 ━ 开发实例之产品管理(WinForm)
RDIFramework.NET V2.8版本 ━ 开发实例之产品管理(WinForm) 现在,我们使用.NET快速开发整合框架(RDIFramework.NET)来开发一个应用,此应用皆在说明如何使 ...
- 一般处理程序返回json
一般处理程序: public void ProcessRequest(HttpContext context) { string action = con ...
- Leetcode: Sort Characters By Frequency
Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: ...
- 字符编码 and cpp
预备知识 字符:抽象的最小文本单位.仅代表符合没有实际意义(如:¥, a, 国) 字符集:字符的集合(如gb2312, ASCII, UNICODE) 编码:是对字符集的描述,计算机要准确的处理各种字 ...