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

我的也是超时15MS!!!!!!!!!!!!!!

Posted by sunmoon at 2005-10-06 17:12:15 on Problem 1002
In Reply To:高手,请帮一下忙,老是超时!!!!!!!!!!!!!!1002 1002 1002 1002 Posted by:589742 at 2005-10-06 16:04:39
我(为了15MS奋斗的人)的也是:
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int main()
{
    int i,j,num,m,flag=1,qq;
    cin>>num;
    char a[]="22233344455566677778889999",s[100],tt[10];  
    long *t=new long[num];
    for(i=0;i<num;i++)
    {
     cin>>s;
     qq=0;
     for(j=0;s[j];j++)
		{
         if (s[j]>='A'&&s[j]<='Z')
          tt[qq++]=a[s[j]-'A'];
         else if(s[j]>='0'&&s[j]<='9')
          tt[qq++]=s[j];
        }
     t[i]=atoi(tt);
    }    
    for(i=0;i<num-1;i++)
    {
     m=i;
     for(j=i+1;j<num;j++)
      if(t[m]>t[j]) m=j;
     if(m!=i) {qq=t[i];t[i]=t[m];t[m]=qq;}
    }      
    for(m=0;m<num;m++)
     {
         i=1;
         while(t[m]==t[m+1]) {i++;flag=0;m++;}
         if(i!=1){
         cout<<setfill('0')<<setw(3)<<t[m-1]/10000<<"-";
         cout<<setfill('0')<<setw(4)<<t[m-1]%10000<<" "<<i<<endl; }       
     }
    if(flag) cout<<"No duplicates."<<endl;
    delete[]t;
    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