POJ 1002 ??????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POJ 1002 ??????相关的知识,希望对你有一定的参考价值。
?????????long ?????? continue cout int namespace ons include ica
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????7??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Q???Z???????????????????????????????????????????????????Q???Z?????????????????????????????????????????????????????????????????????????????????
#include<iostream> #include<algorithm> #include<string> using namespace std; long a[100001]; bool com(const int &x,const int&y) { return x<y; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { string s; cin>>s; for(int j=0;j<s.length();j++) { if(s[j]==???Q???||s[j]==???Z???||s[j]==???-???) { continue; } if(s[j]==???A???||s[j]==???B???||s[j]==???C???) { s[j]=???2???; } if(s[j]==???D???||s[j]==???E???||s[j]==???F???) { s[j]=???3???; } if(s[j]==???G???||s[j]==???H???||s[j]==???I???) { s[j]=???4???; } if(s[j]==???J???||s[j]==???K???||s[j]==???L???) { s[j]=???5???; } if(s[j]==???M???||s[j]==???N???||s[j]==???O???) { s[j]=???6???; } if(s[j]==???P???||s[j]==???R???||s[j]==???S???) { s[j]=???7???; } if(s[j]==???T???||s[j]==???U???||s[j]==???V???) { s[j]=???8???; } if(s[j]==???W???||s[j]==???X???||s[j]==???Y???) { s[j]=???9???; } } long k=0; long m=1; for(int j=s.length()-1;j>=0;j--) { if(s[j]==???-???||s[j]==???Q???||s[j]==???Z???) { continue; } else { k+=((int)s[j]-(int)???0???)*m; m*=10; } } a[i]=k; } sort(a+1,a+n+1,com); bool check=true; int t=0; int count=1; for(int i=2;i<=n+1;i++) { if(i<=n&&a[i]==a[i-1]) { t=a[i]; count++; } else { if(count>=2) { int k=a[i-1]; int t1=k/10000; cout<<t1/100; cout<<(t1-t1/100*100)/10; cout<<t1%10; cout<<"-"; t1=k%10000; cout<<t1/1000; t1=t1-t1/1000*1000; cout<<t1/100; t1=t1-t1/100*100; cout<<t1/10; cout<<t1%10; cout<<" "<<count<<endl; check=false; } count=1; } } if(check) { cout<<"No duplicates."; } return 0; }
以上是关于POJ 1002 ??????的主要内容,如果未能解决你的问题,请参考以下文章