您的位置:首页 > 其它

UVA 755 487-3279

2012-09-01 21:20 302 查看
这写的跑得真慢,不过还是过了。。

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <deque>
#include <map>
using namespace std;
///
#define INF 0xffffff7
#define MAXN 200
///
int nCases;
char num[] = "22233344455566677778889999";
map<string, int> tel;
int main()
{
///
int i, j;
cin >> nCases;
while (nCases--)
{
tel.clear();
int nums;
cin >> nums;
for (i = 0; i < nums; i++)
{
string temp, trans;
cin >> temp;
trans = "";
int k = 0;
for (j = 0; j < temp.size(); j++)
{
if (k == 3)
{
trans += '-';
k++;
j--;
continue;
}
if (isupper(temp[j]))
{
char ch = num[temp[j] - 'A'];
trans += ch;
k++;
continue;
}
if (temp[j] == '-')
continue;
trans += temp[j];
k++;
}
tel[trans]++;
}
bool flag = true;
map<string, int>::iterator it = tel.begin();
while (it != tel.end())
{
if (it->second >= 2)
{
cout << it ->first << " " << it -> second << endl;
flag = false;
}
it++;
}
if (flag)
cout << "No duplicates." << endl;
if (nCases != 0)
cout << endl;
}

///
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: