"POJ" 1002-487-3279

Source: Internet
Author: User

Title: 487-3279
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 255095 Accepted: 45413

Description

Businesses like to has memorable telephone numbers. One-to-make a telephone number memorable are to has 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 are 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 a telephone number memorable is to group the digits in a memorable the. 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 are seven decimal digits with a hyphen between the third and fourth digits (e.g. 88 8-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 was not dialed, and can be added and removed as necessary. The standard form of Tut-glop was 888-4567, the standard form of 310-gino was 310-4466, and the standard form of 3-10-10-10 Is 310-1010.

Telephone numbers is equivalent if they has the same standard form. (They dial the same number.)

Your Company was compiling a directory of telephone numbers from local businesses. As part of the quality control process, you want to check, that no, or more, businesses in the directory has the same t Elephone number.

Input

The input would consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integ Er 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 would be digits or letters.

Output

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

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

Ideas:

Map storage times

Code:
#include <map> #include <cstdio> #include <cstring>using namespace Std;map<char, int> key;int Pre (char *s) {int re = 0;int p = 0;while (s[p]! = ' + ') {if (s[p]! = '-') {if (s[p] >= ' 0 ' && s[p] <= ' 9 ') re = Re * + s[p]-' 0 '; elsere = re * + key[s[p];} ++p;} return re;} int main () {int N;char s[1000];key[' A '] = key[' B '] = key[' C '] = 2;key[' D '] = key[' E '] = key[' F '] = 3;key[' G '] = key[' H '] = key[' I '] = 4;key[' J '] = key[' K '] = key[' L '] = 5;key[' M '] = key[' N '] = key[' O '] = 6;key[' P '] = key[' R '] = key[' S '] = 7;key[ ' T '] = key[' U '] = key[' V '] = 8;key[' W '] = key[' X '] = key[' Y '] = 9;while (EOF! = scanf ("%d", &n)) {map<int, int> m p;for (int i = 0; i < n; ++i) {scanf ("%s", s); ++mp[pre (s)];} Map<int, int>::iterator it;bool flag = 0;for (it = Mp.begin (); It! = Mp.end (); ++it) {if (It->second >= 2) {Prin TF ("%03d-%04d%d\n", it->first/10000, it->first%10000, it->second); flag = 1;}} if (!flag) printf ("No duplicates.\n");} return 0;}


"POJ" 1002-487-3279

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.