poj 1002 487-3279
2017-03-15 21:45
381 查看
记得这是一道大一刚入学死活写不出来的题目,现在已经可以轻松写出,2333
#include<iostream> #include<cstdio> #include<cstring> #include<map> #include<algorithm> using namespace std; const int maxn=1e5+5; map<int,int> count_str; int a[maxn],cnt; char s[105]; int check(char str) { if(str>='A'&&str<='O') return (str-'A')/3+2; else if(str=='P'||str=='R'||str=='S') return 7; else if(str=='T'||str=='U'||str=='V') return 8; else if(str=='W'||str=='X'||str=='Y') return 9; else if(str>='0'&&str<='9') return str-'0'; else return -1; } int main() { int n,i,j,sum,tp; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",s); for(j=sum=0;s[j];j++) { tp=check(s[j]); if(tp==-1) continue; sum*=10; sum+=tp; } if(!count_str[sum]) a[cnt++]=sum; count_str[sum]++; } sort(a,a+cnt); tp=0; for(i=0;i<cnt;i++) if(count_str[a[i]]>1) { printf("%03d-%04d %d\n",a[i]/10000,a[i]%10000,count_str[a[i]]); tp=1; } if(!tp) cout<<"No duplicates."<<endl; return 0; }
相关文章推荐
- poj1002 -- 487-3279
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
- 【POJ】1002. 487-3279
- poj 1002-487-3279
- poj 1002 487-3279 // hoj 1347 487-3279
- POJ1002 487-3279 字符串 C语言
- poj1002 487-3279
- POJ 1002 487-3279
- POJ 1002 487-3279
- poj1002-487-3279
- poj 1002 487-3279
- POJ——1002 487-3279
- POJ 1002 487-3279
- poj 字符串相关之1002 487-3279
- C++——字符串例题——487-3279(POJ1002)
- POJ1002 487-3279
- poj 1002 487-3279
- POJ - 1002 487-3279
- poj 1002 487-3279
- poj 1002 487-3279