[HDU_3652]B-number
题目描述
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task is to calculate how many wqb-numbers from 1 to n for a given integer n.
输入
输出
样例输入
13
100
200
1000
样例输出
1
1
2
2 求小于n是13的倍数且含有“13”的数的个数,有多组数据,输入到结束。 dp[i][j][k][l]。i表示i位数j表示第i位是j的k表示是否包含13(k==0 or 1)L表示膜13是l的数的个数
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int dp[][][][];
int e[];
void init()
{
e[]=;
for(int i=;i<=;i++)e[i]=(e[i-]*)%;
dp[][][][]=;
for(int i=;i<=;i++)
for(int j1=;j1<=;j1++)
for(int j2=;j2<=;j2++)
for(int l=;l<;l++)
{
int yu=(l-(j1*e[i-])%+)%;//yu表示dp[][][][l]从dp[][][][yu]转移//yu+j1贡献的余数=l
dp[i][j1][][l]+=dp[i-][j2][][yu];
if(j1==&&j2==)dp[i][j1][][l]+=dp[i-][j2][][yu];
else dp[i][j1][][l]+=dp[i-][j2][][yu];
}
}
int solve(int a)
{
int len=,ans=,mod=,d[];bool t=;
while(a)
{
d[++len]=a%;a/=;
}
d[len+]=;
for(;len>=;len--)
{
for(int i=;i<d[len];i++)
{
int yu=(-(mod*e[len])%)%;//算上高位mod13的余数还要加多少(yu)mod13才会得0
ans+=dp[len][i][][yu];
if(t||d[len+]==&&i==)ans+=dp[len][i][][yu];
}
if(d[len+]==&&d[len]==)t=;
mod=(mod*+d[len])%;
}
return ans;
}
int main()
{
int n;init();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",solve(n+));
}
return ;
}
[HDU_3652]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 ...
随机推荐
- Open source cryptocurrency exchange
Peatio: https://github.com/peatio/peatio ViaBTC: https://github.com/viabtc/viabtc_exchange_server
- SGU 169 numbers 数学
169.Numbers Let us call P(n) - the product of all digits of number n (in decimal notation). For exam ...
- HDU 6386 Age of Moyu
Problem Description Mr.Quin love fishes so much and Mr.Quin’s city has a nautical system,consisiting ...
- Hbase运维参考(项目)
1 Hbase日常运维 1.1 监控Hbase运行状况 1.1.1 操作系统 1.1.1.1 IO 群集网络IO,磁盘IO,HDFS IO IO越大说明文件读写操作越多.当IO突然增加时,有可能:1. ...
- laravel5.5事件广播系统
目录 1. 定义广播事件 1.1 广播名称 1.2 广播数据 1.3 广播队列 1.4 广播条件 2. 频道授权 2.1 定义授权路由 2.2 定义授权回调 3. 对事件进行广播 3.1 可以使用ev ...
- win7 64位如何共享XP上的打印机?
这个问题看似很简单,但是一旦你遇到了,就会发觉不是想象的那么简单. 除了网上能搜到的一些设置之外,这里还有几个诀窍: 1.首先你必须准备你的打印机的64位驱动程序 2.你在win7上必须采用添加本地打 ...
- 修改MySQL数据库字符集
Preface I've demonstrated how to change character set in Oracle database in my previous blog ...
- 【Python】Django学习一:第一个Django程序
项目开发环境 Python 3.6 Django 1.11.5 Django安装 在开始安装Django之前,Django更新比较频繁,所以要选择合适的版本,这里选择Django1.11.5. pip ...
- 二 APPIUM Android自动化 测试初体验
本文转自:http://www.cnblogs.com/sundalian/p/5629358.html 1.创建一个maven项目 成功新建工程: 编辑pom.xml,在<dependenci ...
- 易语言.开源(绝地求生多功能盒子)类似LOL盒子
下载地址:https://pan.baidu.com/s/1OXwCjGJODkcZVrCwVixu3Q 成品地址:https://pan.lanzou.com/i0rmdwj