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 ...
随机推荐
- ACM核武器
工欲善其事必先利其器,给大家介绍一下ACM里面经常使用的一些工具,平台,作为第一发福利. 详细看这里,我直接粘贴过来有些代码没贴过来 http://wuyiqi.net/house/acm_weap ...
- jvm对大对象分配内存的特殊处理(转)
前段日子在和leader交流技术的时候,偶然听到jvm在分配内存空间给大对象时,如果young区空间不足会直接在old区切一块过去.对于这个结论很好奇,也比较怀疑,所以就上网搜了下,发现还真有这么回事 ...
- POJ1743---Musical Theme(+后缀数组二分法)
Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are int ...
- Win7安装和配置Tigase 5.2server
Win7安装和配置Tigaseserver 笔者:chszs,转载注明. 博客首页:http://blog.csdn.net/chszs 1.下载tigase-server-5.2.0-b3447.e ...
- LCS 小结
转载链接:http://www.cnblogs.com/PJQOOO/p/3897745.html 第一步:先计算最长公共子序列的长度. 实现第一步: 设一个C[i][j]: 保存Xi与Yj的LCS的 ...
- C#关于图片的相关处理
public class ImageHelper { /// <summary> /// 图片转换成字节流 /// </summary> /// <param name= ...
- OData.NET已在 GitHub上开源
OData.NET已在 GitHub上开源 微软最近已将OData .NET所有类库的源代码全部发布在GitHub上. 以下与OData相关的项目目前都已迁移到GitHub上: ODataLib Ed ...
- 【Stackoverflow好问题】java在,如何推断阵列Array是否包括指定的值
问题 java中,怎样推断数组Array是否包括指定的值 精华回答 1. Arrays.asList(...).contains(...) 2. 使用 Apache Commons Lang包中的Ar ...
- 对[foreach]的浅究到发现[yield]
原文:对[foreach]的浅究到发现[yield] 闲来无事,翻了翻以前的代码,做点总结,菜鸟从这里起航,呵呵. 一.List的foreach遍历 先上代码段[1]: class Program { ...
- [CLR via C#]5.4 对象哈希码和dynamic基元类型
原文:[CLR via C#]5.4 对象哈希码和dynamic基元类型 FCL的设计者认为,如果能将任何对象的任何实例放到一个哈希表集合中,会带来很多好处.为此,System.Object提供了虚方 ...