bzoj 1833
f[pos][top]
统计数字个数
g[pos][top][digit]
统计数位(对于f[pos][top]中的所有数)
/**************************************************************
Problem: 1833
User: idy002
Language: C++
Result: Accepted
Time:0 ms
Memory:808 kb
****************************************************************/ #include <cstdio>
#include <cstring> typedef long long poi; poi lf, rg;
int aa[], tot;
poi f[][], g[][][];
poi ans[][]; void calc( poi v, poi ans[] ) {
for( tot=; v; v/= )
aa[++tot] = v%;
memset( f, , sizeof(f) );
memset( g, , sizeof(g) );
f[tot][] = ;
f[tot][] = aa[tot]-;
for( int i=tot; i>=; i-- ) {
f[i-][] = ;
f[i-][] = f[i][]*++f[i][]*aa[i-];
}
g[tot][][aa[tot]] = ;
for( int i=; i<aa[tot]; i++ )
g[tot][][i] = ;
for( int i=tot; i>=; i-- ) {
// for( int s=0; s<=9; s++ )
// g[i-1][0][s] = g[i][0][s]*10+f[i][0]+(s!=0);
for( int s=; s<=; s++ ) {
g[i-][][s] += f[i][];
for( int ss=; ss<=; ss++ ) {
g[i-][][ss] += g[i][][ss];
}
}
for( int s=; s<=; s++ )
g[i-][][s]++;
for( int s=; s<aa[i-]; s++ ) {
g[i-][][s] += f[i][];
for( int ss=; ss<=; ss++ ) {
g[i-][][ss] += g[i][][ss];
}
}
for( int s=; s<=; s++ )
g[i-][][s] = g[i][][s]+(aa[i-]==s);
} for( int i=; i<=; i++ )
ans[i] = g[][][i]+g[][][i];
} int main() {
scanf( "%lld%lld", &lf, &rg );
calc(rg,ans[]);
if( lf> ) calc(lf-,ans[]);
for( int i=; i<=; i++ )
printf( "%lld%s", ans[][i]-ans[][i], i== ? "" : " " );
}
bzoj 1833的更多相关文章
- [BZOJ 1833] [ZJOI2010] count 数字计数 【数位DP】
题目链接:BZOJ - 1833 题目分析 数位DP .. 用 f[i][j][k] 表示第 i 位是 j 的 i 位数共有多少个数码 k . 然后差分询问...Get()中注意一下,如果固定了第 i ...
- [BZOJ 1833] 数字计数
Link: BZOJ 1833 传送门 Solution: 比较明显的数位DP 先预处理出1~9和包括前导0的0的个数:$pre[i]=pre[i-1]*10+10^{digit-1}$ (可以分为首 ...
- BZOJ 1833: [ZJOI2010]count 数字计数
Description 问 \([L,R]\) 中0-9的个数. Sol 数位DP. 预处理好长度为 \(i\), 最高位为 \(j\) 的数位之和. 然后从上往下计算,不要忘记往下走的同时要把高位的 ...
- bzoj 1833 [ZJOI2010]count 数字计数(数位DP)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1833 [题意] 统计[a,b]区间内各数位出现的次数. [思路] 设f[i][j][k ...
- BZOJ 1833: [ZJOI2010]count 数字计数( dp )
dp(i, j, k)表示共i位, 最高位是j, 数字k出现次数. 预处理出来. 差分答案, 对于0~x的答案, 从低位到高位进行讨论 -------------------------------- ...
- BZOJ 1833 count 数字计数
sb数位dp. #include<iostream> #include<cstdio> #include<cstring> #include<algorith ...
- BZOJ 1833 ZJOI2010 count 数字计数 数位DP
题目大意:求[a,b]间全部的整数中0~9每一个数字出现了几次 令f[i]为i位数(算前导零)中每一个数出现的次数(一定是同样的,所以仅仅记录一个即可了) 有f[i]=f[i-1]*10+10^(i- ...
- count 数字计数(bzoj 1833)
Description 给定两个正整数a和b,求在[a,b]中的所有整数中,每个数码(digit)各出现了多少次. Input 输入文件中仅包含一行两个整数a.b,含义如上所述. Output 输出文 ...
- BZOJ 1833 数字计数 数位DP
题目链接 做的第一道数位DP题,听说是最基础的模板题,但还是花了好长时间才写出来..... 想深入了解下数位DP的请点这里 先设dp数组dp[i][j][k]表示数位是i,以j开头的数k出现的次数 有 ...
随机推荐
- spark作业提交参数设置(转)
来源:https://www.cnblogs.com/arachis/p/spark_parameters.html 摘要 1.num-executors 2.executor-memory 3.ex ...
- 【nginx+tomcat集群】Nginx1.12.2+Tomcat7集群+负载均衡+Session共享
今天想着将项目优化一下,就想的实现集群分布,在本机测试:利用nginx+tomcat实现 通过上一篇博客(http://www.cnblogs.com/qlqwjy/p/8535235.html),N ...
- MYSQL的隐式类型转换
官方文档中是这么说的 当操作者使用不同类型的操作数,操作数类型兼容的出现使 转换.一些 发生隐式转换.例如,MySQL会自动 将数字转换为字符串的必要,反之亦然. 也可以将数字转换为字符串明确 使用( ...
- Linux下的lds链接脚本详解【转】
转自:http://www.cnblogs.com/li-hao/p/4107964.html 转载自:http://linux.chinaunix.net/techdoc/beginner/2009 ...
- serialVersionUID的作用(转)
本文系转载,原文链接:http://swiftlet.net/archives/1268 serialVersionUID适用于Java的序列化机制.简单来说,Java的序列化机制是通过判断类的ser ...
- Nginx 原理篇
前言 在学习 Nginx 之前,我们首先有必要搞清楚下面几个问题: 1. Web服务器是怎么工作的? 2. Apache 与 Nginx 有何异同? 3. Nginx 工作模式是怎样的? 下面就围绕这 ...
- oracle相关命令收集-张
orcle相关命令收集 1,用管理员登陆 /as sysdba:2, 更改用户密码 alter user name identified by password: alter user exptest ...
- python中__dict__与dir()的区别
在python中__dict__与dir()都可以返回一个对象的属性,区别在于: __dict__是对象的一个属性,而dir()是一个built-in的方法: __dict__返回一个对象的属性名和值 ...
- 【hdoj_1865】1sting(递推+大数)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1865 本题的关键是找递推关系式,由题目,可知前几个序列的结果,序列长度为n=1,2,3,4,5的结果分别是 ...
- d2i_xxx出错
在生成DER编码是X509_ALGOR类型没有赋值导致,要先new,然后赋值. req_st->req.appKeyReq->appKeyType = X509_ALGOR_new(); ...