OJ百练1002 487-3279
2015-03-07 00:00
369 查看
<span style="font-family: Arial, Helvetica, sans-serif;">#include <iostream></span>
#include <string> #include <vector> #include <algorithm> #include <map> using namespace std; bool judge(const char& ch) { if(ch == '-') return true; else return false; } int main() { int cnt; cin >> cnt; map<char, int> num; string temp; bool flag = true; map<string, int> vec; num['A'] = 2; num['B'] = 2; num['C'] = 2; num['D'] = 3; num['E'] = 3; num['F'] = 3; num['G'] = 4; num['H'] = 4; num['I'] = 4; num['J'] = 5; num['K'] = 5; num['L'] = 5; num['M'] = 6; num['N'] = 6; num['O'] = 6; num['P'] = 7; num['R'] = 7; num['S'] = 7; num['T'] = 8; num['U'] = 8; num['V'] = 8; num['W'] = 9; num['X'] = 9; num['Y'] = 9; while (cnt--) { cin >> temp; temp.erase(remove_if(temp.begin(), temp.end(), judge), temp.end()); for (size_t i = 0; i < temp.size(); ++i) if (isalpha(temp[i])) temp[i] = '0' + num[temp[i]]; vec[temp]++; } for (map<string, int>::const_iterator it = vec.begin(); it != vec.end(); ++it) { string str = it->first; str.insert(3, "-"); if(it->second > 1) { flag = false; cout << str << " " << it->second << endl; } } if(flag) cout <<"No duplicates."<<endl; return 0; }
比较水的一个题,无解的时候需要输出
No duplicates.
一开始没有注意 WA了一次
相关文章推荐
- OJ百练1002 487-3279
- 北大OJ_1002题:487-3279
- poj 1002 487-3279
- poj - 1002 - 487-3279(基数排序)
- POJ 1002 487-3279(水题)
- POJ 1002 487-3279
- POJ-1002-(487-3279)
- POJ 1002 487-3279
- 487-3279(北大OJ核对电话号码)
- poj1002 487-3279
- POJ 1002 487-3279(map)
- PKU ACM 1002 487-3279
- POJ 1002 487-3279 解题报告
- poj 1002 487-3279
- poj 1002 487-3279
- POJ 1002 487-3279(map应用)
- poj 1002 487-3279
- uva 755/poj 1002 487-3279
- POJ 1002 487-3279
- POJ 1002 487-3279(快排)