好久没敲了,感觉都不会了,没事的时候敲敲,其实也很享受。

题目大意:
根据题目的字母与数字对应,把所输入的都转换为7位电话号码。然后按格式输出。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>using namespace std;int arr[10001000];
void change(char *s)
{for (int i = 0; i < 7; i ++){if (s[i] == 'A' || s[i] == 'B' || s[i] == 'C')s[i] = '2';else if (s[i] == 'D' || s[i] == 'E' || s[i] == 'F')s[i] = '3';else if (s[i] == 'G' || s[i] == 'H' || s[i] == 'I')s[i] = '4';else if (s[i] == 'J' || s[i] == 'K' || s[i] == 'L')s[i] = '5';else if (s[i] == 'M' || s[i] == 'N' || s[i] == 'O')s[i] = '6';else if (s[i] == 'P' || s[i] == 'R' || s[i] == 'S')s[i] = '7';else if (s[i] == 'T' || s[i] == 'U' || s[i] == 'V')s[i] = '8';else if (s[i] == 'W' || s[i] == 'X' || s[i] == 'Y')s[i] = '9';}
}int main()
{int n, m, i, j, k, num, temp, v, ans;char ch, s[100];scanf ("%d", &n);while (n --){v = 0;memset(arr, 0, sizeof(arr));scanf("%d%*c", &m);for (i = 0; i < m; i ++)    //读入号码很干去掉,并翻译{ans = 0;num = 0;gets(s);for (j = 0; j < strlen(s); j ++){if (s[j] != '-')s[num ++] = s[j];}s[num] = '\0';        change(s);  temp = 1000000;for (k = 0; k < 7; k ++){ans += (s[k] - '0') * temp;temp /= 10;} arr[ans] ++;}for (i = 0; i < 10001000; i ++){if (arr[i] > 1){v ++;printf("%03d-%04d %d\n", i / 10000, i % 10000, arr[i]);}}if (v == 0)printf("No duplicates.\n");if (n != 0)printf("\n");}return 0;
}
  487-3279 

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2

D, E, and F map to 3

G, H, and I map to 4

J, K, and L map to 5

M, N, and O map to 6

P, R, and S map to 7

T, U, and V map to 8

W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The first line of the input contains the number of datasets in the input. A blank line follows. The first line of each dataset specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. There's a blank line between datasets.

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:

No duplicates.

Print a blank line between datasets.

Sample Input

112
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3
  487-3279 

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2

D, E, and F map to 3

G, H, and I map to 4

J, K, and L map to 5

M, N, and O map to 6

P, R, and S map to 7

T, U, and V map to 8

W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The first line of the input contains the number of datasets in the input. A blank line follows. The first line of each dataset specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. There's a blank line between datasets.

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:

No duplicates.

Print a blank line between datasets.

Sample Input

112
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3

Uva-755-487--3279相关推荐

  1. uva 755 487--3279

    这道题WA了很多次,最后发现输出的时候第三位要带上'-' = =... 而且UVA很坑爹的是不能用strcmpi,strupr!!!! View Code #include<string> ...

  2. 初学者acm的练习题指南

    上机练习题参考题 忘了在哪找的啦~~希望对大家有帮助呦 <!--[if !supportLists]-->1.    <!--[endif]-->Programming Bas ...

  3. ICPC训练联盟2021寒假冬令营(7)_2021.01.26_笔记

    文章目录 试题链接 学习笔记 - C++STL.贪心算法 C++STL 迭代器 STL算法 关联式容器 贪心算法 介绍 使用贪心法能否得到最优解,是必须加以证明的. 体验贪心法内涵的实验范例 贪心法的 ...

  4. UVA 487 - Boggle Blitz

    回溯就可以了 #include <iostream> #include <algorithm> #include <memory.h> #include <c ...

  5. UVa:755 - 487--3279

    题意:找出有重复的电话号码,输出这些号码的标准形式和出现的次数. 当电话号码不足7位时,用'0'补位. 刚开始以为用边输入边比较,最后排序输出是最高效的算法,但一直Time limit exceede ...

  6. Uva 11997 多路归并

    题目链接:https://uva.onlinejudge.org/external/119/11997.pdf 题意: k*k的矩阵,从每一行中选一个元素加起来,可以得到 kk个和,求前 k 个最小值 ...

  7. [搜索]UVa 129 困难的串

    题意:将一个包含两个相邻的重复子串的子串,称为"容易的串",其他为"困难的串". 输入正整数n和l,输出由前l个字符组成的,字典序第n小的困难的串. 输入样例: ...

  8. uva 401.Palindromes

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  9. Uva 3767 Dynamic len(set(a[L:R])) 树套树

    Dynamic len(set(a[L:R])) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 https://uva.onlinejudge.org/in ...

  10. UVA 11752 超级幂

    UVA 11752 超级幂 Z - The Super Powers Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & ...

最新文章

  1. 自学python的书籍逐级推荐-适合初学者和经验的十大最佳Python书籍-2018
  2. [导入]extjs 教程
  3. Alibaba笔试题:根据关键字求最短摘要字串
  4. python numpy np.finfo()函数 eps
  5. python中自定义变量名标识符_name是python的标识符吗
  6. 梯度下降法和随机梯度下降法的区别
  7. C程序设计语言上机13,《高级语言程序设计》北大上机试题(十三)
  8. OpenJudge NOI 1.16 08:石头剪刀布
  9. 川渝严重高温伏旱根源:全球气候变暖导致灾情频发
  10. 把一个整形数组中重复的数字去掉 - 微软面试题
  11. Spring 层次性依赖查找Bean
  12. shell 免杀aspx_记一次aspx网站渗透
  13. opencv3 学习三 - 图像输入输出显示等
  14. 让我们的linux的shell命令待颜色
  15. 使用JDBC增删改查
  16. linux驱动中使用定时器的设置
  17. 计算机网络学习方法和书籍推荐
  18. 《银联提交服务单》-业务流程
  19. Ubuntu下安装Qt
  20. win10显示rpc服务器不可用,多种方法解决Win10专业版RPC服务器不可用的方法

热门文章

  1. 呼吸笔记3-From Fresnel Diffraction Model to Fine-grained Human Respiration Sensing with Commodity Wi-Fi
  2. 2021Java面试心得,Java校招面试指南
  3. 【计算机问题】 火狐浏览器不能下载东西
  4. 海格里斯货架厂:设计阁楼式货架方案时必知三要素
  5. removing-删除
  6. DiskGenius无损换分区表类型为GUID格式或MBR格式
  7. Timus 1295. Crazy Notions
  8. ambari配置ranger
  9. matlab编程练习——每日一练
  10. 什么是Joomla?