题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1368

题目大意:计算从S到T中所有的数,其中0,1,2,3,4,5,6,7,8,9的个数,例如从1024到1032有1024 1025 1026 1027 1028 1029 1030 1031 1032,其中10个0,10个1,7个2,3个3等等

Sample Input

1 10
44 497
346 542
1199 1748
1496 1403
1004 503
1714 190
1317 854
1976 494
1001 1960
0 0

Sample Output

1 2 1 1 1 1 1 1 1 1
85 185 185 185 190 96 96 96 95 93
40 40 40 93 136 82 40 40 40 40
115 666 215 215 214 205 205 154 105 106
16 113 19 20 114 20 20 19 19 16
107 105 100 101 101 197 200 200 200 200
413 1133 503 503 503 502 502 417 402 412
196 512 186 104 87 93 97 97 142 196
398 1375 398 398 405 499 499 495 488 471
294 1256 296 296 296 296 287 286 286 247

代码如下:

 # include<iostream>
# include<cstdio>
# include<cstring>
# include<algorithm>
# include<vector>
using namespace std; int s,t;
int res[],dig[],len; void solve(int num)
{
num ++;
len =;
int temp =;
while()
{
dig[++len] = num%;
num /= ;
if(!num) break;
temp *= ;
}
for(int i=; i<; i++) res[i] += (len-)*temp/;
res[] += (len-)*temp/-(temp-)/;
for(int i=; i<dig[len]; i++)
{
res[i] += temp;
for(int j=; j<; j++)
res[j] += (len-)*temp/;
}
temp /= ;
for(int i=len-; i>=; i--)
{
for(int j=; j<dig[i]; j++)
{
for(int k=len; k>i; k--)
res[dig[k]] += temp;
res[j] += temp;
for(int k=; k<; k++)
res[k] += (i-)*temp/;
}
temp /= ;
}
} int main()
{
while(scanf("%d%d",&s,&t)&& s &&t)
{
memset(res,,sizeof(res));
if(s>t) swap(s,t);
solve(s-);
for(int i=; i<; i++)
res[i] = -res[i];
solve(t);
for(int i=; i<; i++)
printf("%d ",res[i]);
printf("%d\n",res[]);
}
return ;
}

ZOJ 2392 The Counting Problem(模拟)的更多相关文章

  1. ZOJ 3326 An Awful Problem 模拟

    只有在 Month 和 Day 都为素数的时候才能得到糖 那就模拟一遍时间即可. //#pragma comment(linker, "/STACK:16777216") //fo ...

  2. POJ2282 The Counting Problem

    题意 Language:DefaultEspañol The Counting Problem Time Limit: 3000MS Memory Limit: 65536K Total Submis ...

  3. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

  4. UVA 1640 The Counting Problem UVA1640 求[a,b]或者[b,a]区间内0~9在里面各个数的数位上出现的总次数。

    /** 题目:UVA 1640 The Counting Problem UVA1640 链接:https://vjudge.net/problem/UVA-1640 题意:求[a,b]或者[b,a] ...

  5. ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)

    题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...

  6. 『The Counting Problem 数位dp』

    The Counting Problem Description 求 [L,R]内每个数码出现的次数. Input Format 若干行,一行两个正整数 L 和 R. 最后一行 L=R=0,表示输入结 ...

  7. The Counting Problem

    The Counting Problem 询问区间\([a,b]\)中\(1\sim 9\)出现的次数,0 < a, b < 100000000. 解 显然为数位递推,考虑试填法,现在关键 ...

  8. UVALive 3486/zoj 2615 Cells(栈模拟dfs)

    这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常 ...

  9. hdu_5832_A water problem(模拟)

    题目链接:hdu_5832_A water problem 这是一个惨痛的教训,想这种这么大的大数肯定就是找个规律模拟一下. 然而我们队还写JAVA,用大数艹了13发罚时,真是TM智障了. #incl ...

随机推荐

  1. 自定义滚动条CSS样式

    首先,给个默认css,清除掉以前的样式,给默认背景 .scrollbar { margin-left: 30px; float: left; height: 300px; width: 65px; b ...

  2. jboss7的服务器开启和关闭命令

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  3. 【转】从开发者的角度看待各移动平台 ios/android/wp7/win8ost title

    T_T 这伪技术博客都快给写成Tron的读书笔记专栏了,这样可不行欸~ 如今正是移动平台的战国时期,厌烦了去讨论移动平台的未来,也无意于在HTML5和Native App之间纠结.本文只从开发者纯技术 ...

  4. 理解 auto_ptr<T>

    1.auto_ptr<T>解决什么问题? 在堆上获取的资源,客户可能会忘记delete,或者由于异常没有执行到delete,导致资源泄漏.在栈上分配的对象,有个特点,不论出现什么情况,超出 ...

  5. android图片处理方法(不断收集中)

    //压缩图片大小 public static Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ByteArr ...

  6. paip.mysql 5.6 安装总结

    paip.mysql 5.6 安装总结 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/atti ...

  7. 10个你可能从未用过的PHP函数(转)

    1. sys_getloadavg() sys_getloadavt()可以获得系统负载情况.该函数返回一个包含三个元素的数组,每个元素分别代表系统再过去的1.5和15分钟内的平均负载. 与其让服务器 ...

  8. emplace_back与push_back的区别

    std::vector::emplace_back     C++   Containers library   std::vector   template< class... Args &g ...

  9. Using zend-paginator in your Album Module

    Using zend-paginator in your Album Module TODO Update to: follow the changes in the user-guide use S ...

  10. myeclipse安装本地maven fastdfs_client.jar

    为了方便应用程序的访问FastDFS,官网提供了fastdfs-client-java,以便更好的与应用程序结合使用. 下载fastdfs-client-java源码添加到项目工程里面,添加配置文件: ...