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的更多相关文章

  1. POJ 1016 模拟字符串

    Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20396   Accepted: 68 ...

  2. poj 1016 Numbers That Count

    点击打开链接 Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17922   Accep ...

  3. B - Numbers That Count

    Description        "Kronecker's Knumbers" is a little company that manufactures plastic di ...

  4. Numbers That Count POJ - 1016

    "Kronecker's Knumbers" is a little company that manufactures plastic digits for use in sig ...

  5. [LeetCode] Reconstruct Original Digits from English 从英文中重建数字

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...

  6. [LeetCode] Remove K Digits 去掉K位数字

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

  7. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  8. [LeetCode] Add Digits 加数字

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  9. LeetCode 258. Add Digits

    Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only o ...

随机推荐

  1. Android:ViewPager详细解释(异步网络负载图片,有图片缓存,)并与导航点

    android 应用.准则欢迎页面. 和图像旋转木马特征, 或者没有很多其他的内容显示在一个页面.以被划分成多个页面,在这一刻viewpager这是非常容易使用. 首先看下效果: 以下是一个样例.带异 ...

  2. hdu 1542 Atlantis 段树区,并寻求,,,尼玛真坑人数据,不要打开一小阵!

    Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  3. Linq入门演练---(2)lambda表达式

    今天大家一同学习下lambda表达式, lambda表达式使用起来更方便, lambda表达式其实是一个匿名函数,使用的运算符为=> 语法: (参数)=>表达式 如果只有一个参数,可以不使 ...

  4. strip 使用命令

    使用 通过消除使用调试器的粘合剂和符号信息,减少扩展公共对象文件格式(XCOFF)对象文件大小. 语法 strip [ -V ] [ -r [ -l ] | -x [ -l ] | -t | -H | ...

  5. shell变量赋值进阶

    首先,要理解shell中变量的3种赋值情况: unset 例子. unset a 空字符串, null 例子. a='' 非空,即不是unset,并且不是空字符串 例子: a=1 or a=b等 然后 ...

  6. 【github课程】创建github仓库和库创建一个版本号,并添加到存储库文件的版本号

    首先,需要登录github注册一个帐号:https://github.com/ 注册帐号登录后,.在右上角,"新仓库": 然后会出现例如以下的界面: 仅仅须要输入仓库的名称,描写叙 ...

  7. ORA-00932: inconsistent datatypes: expected - got CLOB

    从最近的数据库10.2.0.3升级到10.2.0.5之后,一些对象可以不被编译.查看这些对象的主列表不严格写入之前现在SQL这些语法结果package无法成功编译,诸如select查询列中不能使用混淆 ...

  8. 【动态规划】leetcode - Maximal Square

    称号: Maximal Square Given a 2D binary matrix filled with 0's and 1's, find the largest square contain ...

  9. Spring该讲座

    看看今天Spring. 国内搞Java开发的朋友们.对Spring一定不会陌生. Spring的历史? 谈起Spring.就会想起Ejb2.0.虽然.现实中有非常多基于Ejb2.0的成功系统,可是Ej ...

  10. CSS3 制作向左、向右及关闭图标的效果

    先看一下效果 1.鼠标移入前的效果 2.鼠标移入的效果 3.制作步骤如下: 轮廓的CSS,就是利用圆角和宽度高度,制作出一个圆: <style> /*显示方式为 inline-block* ...