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

为什么啊,为什么WA?都做了1天了~:(

Posted by adamgic at 2005-04-16 17:01:01 on Problem 1002
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
using namespace std;
string str;
int Nums[100000];
const int pows[7]={1000000,100000,10000,1000,100,10,1};
const int x[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};   
int main(void)
{
    freopen("input1002.in","r",stdin);
    int Numbers;
    cin>>Numbers;
    for(int i=0;i<Numbers;i++){
        cin>>str;
        Nums[i]=0;
        int bits=6;
        for(int j=0;j<str.length();j++)
        {
            if(str[j]=='-')continue;
            if(isdigit(str[j])){Nums[i]+=(str[j]-48)*pows[6-bits];bits--;continue;}
            if(isalpha(str[j])){Nums[i]+=x[str[j]-65]*pows[6-bits];bits--;continue;}
        }    
    }       
    sort(Nums,&Nums[Numbers]);
    int temp(0),times(1);
    int dups=0;
    for(int i=0;i<Numbers;i++)
    {
        if(Nums[i]==temp){++times;++dups;}
        else {   
            if(times>1)
                cout<<Nums[i-1]/1000000<<Nums[i-1]%1000000/100000<<Nums[i-1]%100000/10000<<
                "-"<<Nums[i-1]%10000/1000<<Nums[i-1]%1000/100<<Nums[i-1]%100/10<<Nums[i-1]%10<<" "<<times<<endl;
            temp=Nums[i];
            times=1;
        }
    }        
    if(!dups)cout<<"No duplicates."<<endl;
    getch();
}       

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