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 ...
随机推荐
- 它可以作为一个代理server或者转发java类
在项目中使用,这简化和通用汽车.突出的基本思路,细节可以基于此类改变. 基于java容器和servlet. package com.xxx.first; import java.io.Buffered ...
- Android 使用DexClassLoader要执行其他apk方法
Android在apk文件dex文件是java编译出来.class次打包,当然在打包之前会利用自己的协议做一些数据处理,比如优化函数表和变量表.在java程序中是使用classloader来载入这些编 ...
- hdu 3460 Ancient Printer
Problem Description The contest is beginning! While preparing the contest, iSea wanted to print the ...
- javascript系列之变量对象
原文:javascript系列之变量对象 引言 一般在编程的时候,我们会定义函数和变量来成功的构造我们的系统.但是解析器该如何找到这些数据(函数,变量)呢?当我们引用需要的对象时,又发生了什么了? 很 ...
- HDU 3376 && 2686 方格取数 最大和 费用流裸题
题意: 1.一个人从[1,1] ->[n,n] ->[1,1] 2.仅仅能走最短路 3.走过的点不能再走 问最大和. 对每一个点拆点限流为1就可以满足3. 费用流流量为2满足1 最大费用流 ...
- SDUT 1124-飞跃荒野(三维BFS)
飞跃原野 Time Limit: 5000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描写叙述 勇敢的法里奥出色的完毕了任务之后.正在迅速地向自己的基地撤退.但因为 ...
- hadoop排序组合键的使用情况
于hadoop当处理复杂的业务,需要使用组合键,与单纯的复杂的继承Writable接口,但继承WritableComparable<T>接口.事实上.WritableComparable& ...
- PHP+百度地图API+JAVASCRIPT实现GPS坐标与百度坐标转换的实例
原文:PHP+百度地图API+JAVASCRIPT实现GPS坐标与百度坐标转换的实例 <!--小幅的坐标转换点位程序--> <!DOCTYPE html> <html&g ...
- 【百度地图API】如何进行地址解析与反地址解析?——模糊地址能搜索到精确地理信息!
原文:[百度地图API]如何进行地址解析与反地址解析?--模糊地址能搜索到精确地理信息! 摘要: 什么是地址解析? 什么是反地址解析? 如何运用地址解析,和反地址解析? 可以同时运用地址解析,和反地址 ...
- 砸金蛋:jQuery+PHP实现的砸金蛋中奖程序
原文 砸金蛋:jQuery+PHP实现的砸金蛋中奖程序 砸金蛋被广泛应用于庆典活动.商家促销.电视娱乐等场合,它的趣味.悬念能迅速活跃现场气氛.同样,我们也可以将砸金蛋应用到WEB网站上,用于开展线上 ...