Accepted | 1159 | C++ | 00:03.33 | 3280K |
STL写的,效率超低,不过代码很简单。
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
const int aph[26] = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, -1, 7, 7, 8, 8, 8, 9, 9, 9, -1 };
void solve(int n)
{
int cnt = 0, flag = 0 ;
map<int, int> table;
for(int i = 0; i < n; i++ )
{
int temp = 0 ;
char c;
while(scanf("%c", &c) != EOF && c != ' ' )
if(c != '-' )
temp = (10 * temp + ((c >= 'A' && c <= 'Z') ? aph[c - 'A'] : (c - '0' )));
table[temp]++ ;
}
for(map<int, int>::iterator it = table.begin(); it != table.end(); it++ )
{
int temp = it-> second;
if(temp > 1 )
{
int p1 = (it->first) / 10000, p2 = (it->first) % 10000 ;
if(p1 < 10) printf("00" );
else if(p1 < 100) printf("0" );
printf("%d-" , p1);
if(p2 < 10) printf("000" );
else if(p2 < 100) printf("00" );
else if(p2 < 1000) printf("0" );
printf("%d %d/n" , p2, temp);
flag = 1 ;//其实很不想用flag的,不爽.
}
}
if(flag == 0 )
printf("No duplicates./n" );
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1159.txt", "r" , stdin);
#endif
int t, n;
while(scanf("%d", &t) != EOF)
for(int i = 0; i < t; i++ )
{
if(i > 0) printf("/n" );
scanf("%d/n", & n);
solve(n);
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0 ;
}
#include <string.h>
#include <map>
using namespace std;
const int aph[26] = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, -1, 7, 7, 8, 8, 8, 9, 9, 9, -1 };
void solve(int n)
{
int cnt = 0, flag = 0 ;
map<int, int> table;
for(int i = 0; i < n; i++ )
{
int temp = 0 ;
char c;
while(scanf("%c", &c) != EOF && c != ' ' )
if(c != '-' )
temp = (10 * temp + ((c >= 'A' && c <= 'Z') ? aph[c - 'A'] : (c - '0' )));
table[temp]++ ;
}
for(map<int, int>::iterator it = table.begin(); it != table.end(); it++ )
{
int temp = it-> second;
if(temp > 1 )
{
int p1 = (it->first) / 10000, p2 = (it->first) % 10000 ;
if(p1 < 10) printf("00" );
else if(p1 < 100) printf("0" );
printf("%d-" , p1);
if(p2 < 10) printf("000" );
else if(p2 < 100) printf("00" );
else if(p2 < 1000) printf("0" );
printf("%d %d/n" , p2, temp);
flag = 1 ;//其实很不想用flag的,不爽.
}
}
if(flag == 0 )
printf("No duplicates./n" );
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1159.txt", "r" , stdin);
#endif
int t, n;
while(scanf("%d", &t) != EOF)
for(int i = 0; i < t; i++ )
{
if(i > 0) printf("/n" );
scanf("%d/n", & n);
solve(n);
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0 ;
}