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. 笔试题&amp;面试题:设计一个复杂度为n的算法找到单向链表倒数第m个元素

    设计一个复杂度为n的算法找到单向链表倒数第m个元素.最后一个元素假定是倒数第0个. 提示:双指针查找 相对于双向链表来说,单向链表仅仅能从头到尾依次訪问链表的各个节点,所以假设要找链表的倒数第m个元素 ...

  2. 设计模式之享元模式(Flyweight)摘录

    23种GOF设计模式一般分为三大类:创建型模式.结构型模式.行为模式. 创建型模式抽象了实例化过程,它们帮助一个系统独立于怎样创建.组合和表示它的那些对象.一个类创建型模式使用继承改变被实例化的类,而 ...

  3. jquery选择器中逗号的使用

    1.多条件选择器 多条件选择器:$("p,div,span.menuitem"),同时选择p标签,div标签,和拥有menuitem样式的span标签元素 <table id ...

  4. Asp.Net MVC 2.0 Filter基本用法

    在这一节里,大家一同学习下mvc 2.0中的filter,简单的说,filter就是标记在action上的一些属性,来实现对action的控制. mvc2.0中主要包括以下filter 1. Auth ...

  5. android进度条

    android进度条 1.达到的效果 2.布局代码 先写一个my_browser.xml文件 存放WebView <?xml version="1.0" encoding=& ...

  6. UVA - 10014 - Simple calculations (经典的数学推导题!!)

    UVA - 10014 Simple calculations Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & ...

  7. [ACM] poj 1064 Cable master (二进制搜索)

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21071   Accepted: 4542 Des ...

  8. C语言学习之路,第一篇章。

    看的书是 C  primer plus  ,这本书好评很多, 学过C#,没有精通,了解Java,所以看这本书会很容易上手,编译器用的是VC++6.0,因为VS2010好像不支持C99标准,有些代码功能 ...

  9. 我的MYSQL学习心得(九)

    原文:我的MYSQL学习心得(九) 我的MYSQL学习心得(九) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL学习心得(四) 我的MYSQL ...

  10. 平安某金所奇葩的面经-关于幂等和ROA设计的反思

    在公司一直在做跟支付有关的项目,某日接到平安某金所一男子电话,应该是之前某猎头投的,我正好在吃早饭(也不能怪他们上班早,我们公司弹性工作制,我一般上班比较晚). 因为饭馆信号不好,只能赶紧放下剩下的半 ...