标签:move enter ogr 比较 bre tween lis ras map
http://poj.org/problem?id=1002
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 288073 | Accepted: 51697 |
Description
Input
Output
Sample Input
12 4873279 ITS-EASY 888-4567 3-10-10-10 888-GLOP TUT-GLOP 967-11-11 310-GINO F101010 888-1200 -4-8-7-3-2-7-9- 487-3279
Sample Output
310-1010 2 487-3279 4 888-4567 3
注意:如果算法里采用转化成整数比较比对,注意最后输出时,数字长度可能小于7的情况。
代码:
1 #include <cstdio> 2 #include <map> 3 4 int StrToNum (const char *t, int len); 5 6 int main () 7 { 8 int count, tmp32; 9 scanf("%d", &count); 10 getchar(); 11 12 std::map<int, int> stlm; 13 std::map<int, int>::iterator it; 14 15 char c[20]; 16 int clen; 17 18 for (int i = 0; i < count; i++) 19 { 20 for (clen = 0; ; clen++) 21 { 22 while (scanf("%c", &c[clen]), c[clen] == ‘-‘) 23 { 24 } 25 26 if (c[clen] == ‘\n‘) 27 { 28 break; 29 } 30 } 31 32 tmp32 = StrToNum(c, clen); 33 it = stlm.find(tmp32); 34 if (it == stlm.end()) 35 { 36 stlm[tmp32] = 1; 37 } 38 else 39 { 40 stlm[tmp32]++; 41 } 42 } 43 44 bool bret = false; 45 for (it = stlm.begin(); it != stlm.end(); it++) 46 { 47 if (it->second > 1) 48 { 49 bret = true; 50 printf("%03d-%04d %d\n", (it->first) / 10000, (it->first) % 10000, it->second); 51 } 52 } 53 54 if (!bret) 55 { 56 puts("No duplicates."); 57 } 58 59 return 0; 60 } 61 62 int StrToNum (const char *t, int len) 63 { 64 int j = 0, v = 0; 65 66 for (int i = 0; ; i++) 67 { 68 switch (t[i]) 69 { 70 case ‘A‘: 71 v += 2; 72 break; 73 case ‘B‘: 74 v += 2; 75 break; 76 case ‘C‘: 77 v += 2; 78 break; 79 case ‘D‘: 80 v += 3; 81 break; 82 case ‘E‘: 83 v += 3; 84 break; 85 case ‘F‘: 86 v += 3; 87 break; 88 case ‘G‘: 89 v += 4; 90 break; 91 case ‘H‘: 92 v += 4; 93 break; 94 case ‘I‘: 95 v += 4; 96 break; 97 case ‘J‘: 98 v += 5; 99 break; 100 case ‘K‘: 101 v += 5; 102 break; 103 case ‘L‘: 104 v += 5; 105 break; 106 case ‘M‘: 107 v += 6; 108 break; 109 case ‘N‘: 110 v += 6; 111 break; 112 case ‘O‘: 113 v += 6; 114 break; 115 case ‘P‘: 116 v += 7; 117 break; 118 case ‘R‘: 119 v += 7; 120 break; 121 case ‘S‘: 122 v += 7; 123 break; 124 case ‘T‘: 125 v += 8; 126 break; 127 case ‘U‘: 128 v += 8; 129 break; 130 case ‘V‘: 131 v += 8; 132 break; 133 case ‘W‘: 134 v += 9; 135 break; 136 case ‘X‘: 137 v += 9; 138 break; 139 case ‘Y‘: 140 v += 9; 141 break; 142 default: 143 v += t[i] - ‘0‘; 144 } 145 146 if (i + 1 < len) 147 { 148 v *= 10; 149 } 150 else 151 { 152 break; 153 } 154 } 155 156 return v; 157 }
标签:move enter ogr 比较 bre tween lis ras map
原文地址:http://www.cnblogs.com/jiu0821/p/6568907.html