Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我用的map+int来算,可老是WA,在本地侧没有问题阿,那位高手来帮忙看一下#include <iostream> #include <map> #include <string> #include <math.h> #include <iomanip> using namespace std; int main() { bool dup=false; int n,m,count; map <long,int> number; map <long,int>::iterator it; long numTmp; string numInput; const int nummap[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9}; cin >> n; for( int i = 0; i < n; i++) { cin>>numInput; count = 7; numTmp = 0; m = 0; while(count) { if(numInput[m]>='0'&&numInput[m]<='9') { numTmp+=(numInput[m]-'0')*int(pow( 10.0,--count)); } else if(numInput[m]>='A'&&numInput[m]<='Z') { numTmp+=nummap[numInput[m]-'A']*int(pow( 10.0,--count)); } m++; } number[numTmp] += 1; } for( it = number.begin();it != number.end(); it++) { if((*it).second>1) { cout<<setfill('0') <<setw( 3) <<(*it).first/10000 <<'-' <<setfill('0') <<setw(4) <<(*it).first%10000 <<' '<<(*it).second <<endl; dup=true; } } if( dup == false ) cout << "No duplicates." << endl ; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator