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 ...
随机推荐
- UVALive 4730 Kingdom +段树和支票托收
主题链接:点击打开链接 题意见白书P248 思路: 先把读入的y值都扩大2倍变成整数 然后离散化一下 用线段树来维护y轴 区间上每一个点的 城市数量和联通块数量. 然后用并查集维护每一个联通块及联通块 ...
- DevExpress XtraReports 入门四 创建 Web 报表
原文:DevExpress XtraReports 入门四 创建 Web 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这 ...
- Hard Parse&Soft Parse
DDL每次运行将必须是难以解决. SQL 解析过程 Oracle对此SQL将进行几个步骤的处理过程: 1.语法检查(syntax check): 检查此sql的拼写是否语法. 2.语义检查(seman ...
- .NET平台机器学习
.NET平台机器学习资源汇总,有你想要的么? 接触机器学习1年多了,由于只会用C#堆代码,所以只关注.NET平台的资源,一边积累,一边收集,一边学习,所以在本站第101篇博客到来之际,分享给大家.部分 ...
- 编程算法 - 切割排序 代码(C)
切割排序 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 排序切割, 把一个数组分为, 大于k\小于k\等于k的三个部分. 能够使用高速排序的Parti ...
- SignalR的实时高频通讯
SignalR的实时高频通讯 第五章SignalR的实时高频通讯 概述:本例子演示了如果创建一个对象与其他浏览器共享实时状态的应用程序.我们要创建的应用程序为“MoveShape”,该MoveShap ...
- UVA - 817 According to Bartjens
Description According to Bartjens The wide dissemination of calculators and computers has itsdisad ...
- .net EF 事物 订单流水号的生成 (二):观察者模式、事物、EF
针对.net EF 事物 订单流水号的生成 (一) 的封装. 数据依然不变. using System; using System.Linq; using System.Transactions; ...
- 再谈IE的浏览器模式和文档模式
原文:再谈IE的浏览器模式和文档模式 以前在 “IE8兼容视图(IE7 mode)与独立IE7的区别”一文中曾经涉及过浏览器模式和文档模式,但二者的区别却不甚了了,现在有了新的认识,再补充一下. 1. ...
- Android KeyStore Stack Buffer Overflow (CVE-2014-3100)
/* 本文章由 莫灰灰 编写,转载请注明出处. 作者:莫灰灰 邮箱: minzhenfei@163.com */ 1. KeyStore Service 在Android中,/system/bi ...