hdu3652B-number
100
200
1000
1
2
2
题解:
设f[i][j][r][0/1]表示i位数(可含前导0)第一位为j,mod13的余数是r,有没有出现13(0/1)的数有几个
code:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxl=;
const int maxnum=;
const int rest=;
int n,power[maxl],f[maxl][maxnum][rest][],a[maxl];
void init(){
power[]=;
for (int i=;i<=;i++) power[i]=power[i-]*%;
f[][][][]=;
for (int i=;i<=;i++) for (int j=;j<=;j++)
for (int k=;k<=;k++) for (int r=;r<;r++){
int tmp=(r+j*power[i])%;
if (!(j==&&k==)) f[i][j][tmp][]+=f[i-][k][r][];
else f[i][j][tmp][]+=f[i-][k][r][];
f[i][j][tmp][]+=f[i-][k][r][];
}
}
int calc(int n){
int ans=,t=n,len=,r=,tmp;
bool flag=;
memset(a,,sizeof(a));
while (t) a[++len]=t%,t/=;
for (int i=len;i;i--){
for (int j=;j<a[i];j++){
tmp=((-(r+j*power[i]))%+)%;
for (int k=;k<=;k++) ans+=f[i-][k][tmp][];
if (!flag){
if (a[i+]==){if (j==) for (int k=;k<=;k++) ans+=f[i-][k][tmp][];}
if (j==) ans+=f[i-][][tmp][];
}
else for (int k=;k<=;k++) ans+=f[i-][k][tmp][];
}
r+=a[i]*power[i],r%=;
if (a[i+]==&&a[i]==) flag=;
}
return ans;
}
int main(){
init();
while (~scanf("%d",&n)) printf("%d\n",calc(n+));
return ;
}
hdu3652B-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 ...
随机推荐
- 一个Hibernate小程序
基本步骤 在前一篇博文Hibernate环境搭建中为大家详细的介绍如何搭建一个学习新类库的学习环境.今天,为大家带来一个Hibernate小例子,让大家能够快速上手. 步骤如下: 1.配置hibern ...
- SDUTRescue The Princess(数学问题)
题目描述 Several days ago, a beast caught a beautiful princess and the princess was put in prison. To re ...
- 微信公众号支付流程(Node实现)
前言 花费了一天时间,调通了微信公众号支付.作下记录,方便以后再次填坑.先声明,微信公众号支付,不同于微信H5支付,这点在本文结束时再详细说明. 微信配置 设置测试目录 在微信公众平台设置,栏目见下图 ...
- jetty服务器访问系统的域名
jetty-env.xml=><Set name="contextPath">/epps-compensation-backend</Set> 这个决 ...
- Fluent NHibernate之旅
Fluent NHibernate 之旅 导航篇: [原创]Fluent NHibernate之旅开篇: [原创]Fluent NHibernate之旅二--Entity Mapping: [原创]F ...
- 分享整理的sql脚本
1. 表空间使用率 SQL> select a.tablespace_name, 2 round(a.total_size) "total_size M" ...
- PV、UV、IP的区别
网站推广需要一个网站访问统计工具,常用的统计工具有百度统计.51la.量子恒道统计等.网站访问量常用的指标为PV.UV.IP.那么什么是PV.UV和IP,PV.UV.IP的区别是什么? --首先来看看 ...
- Xaml中的资源(1 样式)
<Window x:Class="MyResoures.MainWindow" xmlns="http://schemas.microsoft.com/winfx/ ...
- ubuntu系统安装的MySql数据库,远程不能访问的几种可能问题
安装MySQL数据库后一般会遇到远程计算机不能连接的问题,具体问题需要我们排查.可能一:MySql数据库是否提供了外部访问的用户以及权限?可能二:MySql的配置文件是否只绑定了本机ip(ubuntu ...
- SGU 196.Matrix Multiplication
时间限制:0.25s 空间限制:4M Solution n=10000,m=100000,显然不能用矩阵乘法乘出来. S= ATA 对于矩阵S的一行,所有在A矩阵中1位置的元素都相等,并且都等于这一行 ...