SZU:A66 Plastic Digits
2014-02-15 15:34
543 查看
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![](http://acm.szu.edu.cn/wiki/images/math/8/c/d/8cd9c6955e56c09def8c6a0b44986886.png)
which is the number of test cases. T test cases follow.
Each test case contains two positive integers
![](http://acm.szu.edu.cn/wiki/images/math/4/8/4/48425f3078fb660476c45fe0b1a635f7.png)
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 :
1 #include <stdio.h> 2 #include <string.h> 3 int A[10]; 4 5 int main() 6 { 7 int t, a, b,i,j,num,tmp; 8 scanf("%d", &t); 9 while(t--){ 10 memset(A,0,sizeof(A)); 11 scanf("%d%d",&a,&b); 12 if(b<a){ 13 tmp = a; 14 a = b; 15 b = tmp; 16 } 17 int j=0; 18 for(i=a;i<=b;++i){ 19 num = i; 20 while(num>9){ 21 A[num%10]++; 22 num/=10; 23 } 24 if(num<10) 25 A[num]++; 26 } 27 for(i=0;i<10;++i) 28 printf("%d %d\n", i,A[i]); 29 if(t!=0) 30 printf("\n"); 31 32 } 33 return 0; 34 }
相关文章推荐
- SZU:A66 Plastic Digits
- Solaris Xen Drop 66 - Setup Fedora HVM DomU
- LCC编译器的源程序分析(66)DAG树分析例子
- LCC编译器的源程序分析(66)DAG树分析例子
- 再学 GDI+[66]: 路径画刷(6) - SetInterpolationColors、GetRectangle
- reactos操作系统实现(66)
- GCC-3.4.6源代码学习笔记(66)
- Android培训班(66)dex文件打开流程
- Python自然语言处理学习笔记(66):7.7 小结
- 裸考—歪理邪说解析系统分析师上午考试试题之十四(分析2010上半年系统分析师上午试题66-70题)
- 基于visual c++之windows核心编程代码分析(66)实现Windows服务的远程控制
- 配置OpenCV产生flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe问题
- SZU:A26 Anagram
- 每日一题(66) - 字符串的排列
- 网络子系统66_策略路由初始化
- C66xDSP芯片—semaphore 2 介绍
- SZU:A26 Anagram
- Effective Java 66 Synchronize access to shared mutable data
- 环保创业的可行之道——Leo鉴书上66
- 【刷题小记66】分拆数