SZU:A66 Plastic Digits
Description
There is a company that makes plastic digits which are primarily put on the front door of each house to form the house number. In order to make sure that they don’t waste any resources, they want to make the exact number of digits for the house numbers needed. You are to write a program to help the company decide how many copies of each digit it needs to make for each order it receives.
Input
The input will contains multiple test cases. The first line of the input is a single integer
which is the number of test cases. T test cases follow.
Each test case contains two positive integers
which indicate the range of house numbers the company has to make for a particular order. The range is inclusive of n and m.
Output
For each input test case, you are to output the number of copies of each digit that the company needs to make in the following format:
- 0 <number of copies of digit 0>
- 1 <number of copies of digit 1>
- ...
- ...
- ...
- 9 <number of copies of digit 9>
There should be a single space between the digit and the required copies.
There should be a single blank line between two test cases. No blank line at the end of the last test case.
Sample Input
2
1 13
1 13
Sample Output
0 1
1 6
2 2
3 2
4 1
5 1
6 1
7 1
8 1
9 1 0 1
1 6
2 2
3 2
4 1
5 1
6 1
7 1
8 1
9 1
解题思路:范围 n , m 并没有说 m>n 所以要判断范围 , if n>m swap(n, m)
My code :
#include <stdio.h>
#include <string.h>
int A[]; int main()
{
int t, a, b,i,j,num,tmp;
scanf("%d", &t);
while(t--){
memset(A,,sizeof(A));
scanf("%d%d",&a,&b);
if(b<a){
tmp = a;
a = b;
b = tmp;
}
int j=;
for(i=a;i<=b;++i){
num = i;
while(num>){
A[num%]++;
num/=;
}
if(num<)
A[num]++;
}
for(i=;i<;++i)
printf("%d %d\n", i,A[i]);
if(t!=)
printf("\n"); }
return ;
}
SZU:A66 Plastic Digits的更多相关文章
- POJ 1016 模拟字符串
Numbers That Count Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20396 Accepted: 68 ...
- poj 1016 Numbers That Count
点击打开链接 Numbers That Count Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17922 Accep ...
- B - Numbers That Count
Description "Kronecker's Knumbers" is a little company that manufactures plastic di ...
- Numbers That Count POJ - 1016
"Kronecker's Knumbers" is a little company that manufactures plastic digits for use in sig ...
- [LeetCode] Reconstruct Original Digits from English 从英文中重建数字
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...
- [LeetCode] Remove K Digits 去掉K位数字
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Add Digits 加数字
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- LeetCode 258. Add Digits
Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only o ...
随机推荐
- scala 101
* scala 安装: 下载可以执行的文件. 注意版本. spark 0.8.0 对应的scala 为2.9.3 * scala 编译: 和java 很像: 1, 直接编译脚本: scalac H ...
- 使用 CodeIgniter 框架快速开发 PHP 应用(一)
原文:使用 CodeIgniter 框架快速开发 PHP 应用(一) 对 CodeIgniter 的介绍大多数PHPer都想写出运行状态良好的应用程序,而且希望尽可能做得简单且不费事.这篇文章是有关 ...
- git branch(转)
git branch git branch 不带参数:列出本地已经存在的分支,并且在当前分支的前面加“*”号标记,例如: #git branch* master newbranch gi ...
- 用Maven整合SpringMVC+Spring+Hibernate 框架,实现简单的插入数据库数据功能
一.搭建開始前的准备 1.我用的MyEclipse2014版,大家也能够用IDEA. 2.下载Tomcat(免安装解压包).MySQL(zip包下载地址 免安装解压包,优点就是双击启动,最后我会把ba ...
- Oracle内存管理(五)
[深度分析--eygle]学习笔记 1.4. 2其他内存组件 Large Pool-大池是SGA的一个可选组件,通经常使用于共享server模式(MTS). 并行计算或 RMAN的备份恢复等操作. J ...
- Java多线程的~~~Lock接口和ReentrantLock使用
在多线程开发.除了synchronized这个keyword外,我们还通过Lock接口来实现这样的效果.由Lock接口来实现 这样的多线程加锁效果的优点是非常的灵活,我们不在须要对整个函数加锁,并且能 ...
- 记录近期小改Apriori至MapReduce上的心得
·背景 前一阵,一直在研究一些ML的东东,后来工作关系暂停了一阵.现在继续把剩下一些热门的算法再吃吃透,"无聊+逗比"地把他们搞到MapReduce上.这次选择的入手对象为Apri ...
- NGUI使用教程(2) 使用NGUI创建2D场景而且加入标签和button
1.创建2D场景 要使用NGUI创建2D场景,首先咱们必须新建一个项目,而且导入NGUI作为这个项目的插件,相信假设看过上一篇教程都知道怎么导入NGUI了,这里就不赘述,假设有疑问的能够去看上一篇教程 ...
- JDK动态代理机制
JDK Proxy OverView jdk的动态代理是基于接口的.必须实现了某一个或多个随意接口才干够被代理.并且仅仅有这些接口中的方法会被代理. 看了一下jdk带的动态代理api,发现没有样例实在 ...
- Floodlight controller 线程池模型
官方文档对于ThreadPool的描写叙述是:ThreadPool is a Floodlight module wrapper for a Java's ScheduledExecutor ...