Ultraviolet A 755-487-3279

Source: Internet
Author: User

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 cocould 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 shoshould 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
1124873279ITS-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

A duplicate phone number is required,

First, convert the string into a number as required. At the beginning, you want to be lazy and sort the 10000000 array in the bucket. Then, a phone number is counted as seven digits and output, the result is runtime error failed.

Then, you can only store up to 10 ^ 5 numbers as required for fast sorting, and then output them. The last data does not need to wrap the wrong several times.

In addition, the output must be a seven-digit number. Therefore, it is very convenient to add 0 to printf directly after learning other people's writing methods.

I learned how to use the qsort of STL. I don't know why it times out when I use a self-written quick rank. I have used the quick rank template for many years and it times out, the library function qsort does not Time Out ~~~~ (>_< )~~~~

# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>
Int comp (const void * a, const void * B)
{Return * (int *) A-* (int *) B ;}
Void main ()
{Char s [300];
Int Alpha [27] = {, 9, 9, 0}, I, j, n, l, number, sum, T;
Int A [100001];
Scanf ("% d", & T );
While (t --)
{
Scanf ("% d \ n", & N );
For (j = 0; j <n; j ++)
{Scanf ("% s", & S );
Number = 0;
L = strlen (s );
For (I = 0; I <L; I ++)
{If (S [I]> = 'A') & (s [I] <= 'Z ')) number = Number * 10 + Alpha [s [I]-'a'];
If (S [I]> = '0') & (s [I] <= '9 ')) number = Number * 10 + s [I]-'0 ';
}
A [J] = number;
}
Qsort (A, N, sizeof (INT), comp );
I = 0; sum = 0;
While (I <n-1)
{J = I;
While (j <n-1) & (A [J] = A [J + 1]) J ++;
If (j> I) {printf ("% 03d-% 04d % d \ n", a [I]/10000, a [I] % 10000, j-I + 1); ++ sum ;}
I = J + 1;
}
If (sum = 0) printf ("no duplicates. \ n ");
If (t) printf ("\ n ");
}
}

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.