Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

终于ac了,但时间消耗也太大了,是因为用map的关系吗?

Posted by czq1285 at 2005-09-22 17:03:09 on Problem 1002
In Reply To:我用的map+int来算,可老是WA,在本地侧没有问题阿,那位高手来帮忙看一下 Posted by:czq1285 at 2005-09-22 15:43:11
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator