487-3279[POJ1002]

Source: Internet
Author: User

487-3279
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 284182 Accepted: 51001

Description

companies like to use phone numbers that are easy to remember. One way to make a phone number easy to remember is to write it as an easy-to-remember word or phrase. For example, when you need to call the University of Waterloo, you can call Tut-glop. Sometimes, only some numbers in a phone number are spelled as words. When you return to the hotel at night, you can order a pizza by dialing 310-gino to Gino ' s. Another way to make phone numbers easy to remember is to group numbers in a well-remembered way. By calling the "three ten" numbers at Pizza Hut 3-10-10-10, you can order pizza from them.
the standard format for a phone number is a seven-bit decimal number, and there is a connector between the third and fourth digits. The telephone dials provide a mapping of letters to numbers, and the mapping relationships are 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 mapped to 8
W, X, and y mapped to 9
Q and Z do not map to any number, hyphens do not need to be dialed and can be arbitrarily added and deleted. The standard format for Tut-glop is the standard format of the 888-4567,310-gino is 310-4466,3-10-10-10, which is 310-1010.
If two numbers have the same standard format, then they are equal (same dialing)
your company is writing a phone number for a local company. As part of quality control, you want to check if there are two or more companies that have the same phone number.

Input

the input format is that the first line is a positive integer specifying the number of numbers in the phone book (up to 100000). Each of the remaining lines is a phone number. Each phone number consists of numbers, uppercase letters (except Q and z), and connectors. Each phone number is just 7 digits or letters.

Output

for each duplicate number that produces a row of output, the output is the standard format of the number immediately following a space followed by the number of repetitions. If there are multiple duplicate numbers, it is output in ascending order by the dictionary of the numbers. If there are no duplicate numbers in the input data, one line is output:
No duplicates.

Sample Input

124873279its-easy888-45673-10-10-10888-gloptut-glop967-11-11310-ginof101010888-1200-4-8-7-3-2-7-9-487-3279

Sample Output

310-1010 2487-3279 4888-4567 3

#include <stdio.h>#include<algorithm>using namespacestd;inta[110000];Const intb[ -] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};intMain () {intN, x; Charch; scanf ("%d", &N);  for(inti =0; I < n; i++) {x=0;  for(intj =0; J <7; J + +) {             while(1) {ch=GetChar (); if(('0'<= CH && Ch <='9') || ('A'<= CH && Ch <='Z')) {                     Break; }            }            if('0'<= CH && Ch <='9') {x= x *Ten+ CH-'0'; } Else{x= x *Ten+ B[ch-'A']; }} A[i]=x; } sort (A, a+N); A[n]= -1; BOOLf =false; intt =1;  for(inti =0; I < n; i++) {        if(A[i] = = A[i +1]) {f=true; T++; } Else {            if(T >1) {printf ("%03d-%04d%d\n", A[i]/10000, A[i]%10000, T); T=1; }        }    }    if(!f) {printf ("No duplicates. \ n"); }    return 0;}
View Code



487-3279[POJ1002]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.