SZU:A66 Plastic Digits
2013-07-18 12:54
176 查看
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 :
#include <stdio.h> #include <string.h> int A[10]; int main() { int t, a, b,i,j,num,tmp; scanf("%d", &t); while(t--){ memset(A,0,sizeof(A)); scanf("%d%d",&a,&b); if(b<a){ tmp = a; a = b; b = tmp; } int j=0; for(i=a;i<=b;++i){ num = i; while(num>9){ A[num%10]++; num/=10; } if(num<10) A[num]++; } for(i=0;i<10;++i) printf("%d %d\n", i,A[i]); if(t!=0) printf("\n"); } return 0; }
相关文章推荐
- SZU:A66 Plastic Digits
- Solaris Xen Drop 66 – Xen System Administration
- 硬盘结构简介http://www.x86asm.com/Print.asp?BoardID=7&ArticleID=66
- LCC编译器的源程序分析(66)DAG树分析例子
- debug时出现的DB 66和DB C1
- NetBeans 时事通讯(刊号 # 66 - Jul 30, 2009)
- 面试66问经典回答
- 查询内并行度导致服务器命令(进程 ID #66)死锁。请重新运行该查询,并在查询中用查询暗示选项 (maxdop 1) 去掉查询内并行度
- 基于visual c++之windows核心编程代码分析(66)实现Windows服务的远程控制
- NYOJ66-分数拆分
- Ciscodk 新增科目:C_TSCM52_66
- [Leetcode 4] 66 Plus One
- SZU:L89 Frog Encoding
- ocp-047-66
- 配置OpenCV产生flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe问题
- 微信公众平台开发(66)人品计算
- SZU:L89 Frog Encoding
- LeetCode 66 — Plus One(C++ Java Python)
- iOS Dev (66) 一个手机游戏程序的基本考虑
- 66. Regular Expression Matching