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 T^T

Posted by nf001 at 2012-11-12 16:43:11 on Problem 1002
#include <iostream>
#include <string>
using namespace std;
int o[10000000];

int trans(char x)
{
    if (x<='9'&&x>='0') return(x-'0');
    else
        if (x<='O')
            return((x-'A')/3+2);
        else
        {
            if (x=='P'||x=='R'||x=='S') return 7;
            if (x=='T'||x=='U'||x=='V') return 8;
            if (x=='W'||x=='X'||x=='Y') return 9;
        }
}

int main()
{
    string s;
    int n,l,k=0;
    int num=0;
    cin>>n;
    for (int i=1;i<=n;++i)
    {
        cin>>s;
        l=s.length();
        num=0;
        for (int j=0;j<=l-1;++j)
            if (s[j]!='-')
                num=num*10+trans(s[j]);
		++o[num];
    }
	int kk=0;
    for (int i=0;i<=10000000;++i)
    {
        if (o[i]>1)
        {
            kk=1;num=i;s="";
			for (int j=0;j<=6;++j)
			{
				s=char(num%10+48)+s;
				num/=10;
				if (j==3) s='-'+s;
			}
                cout<<s;
            cout<<' '<<o[i]<<endl;
        }
    }
	if (!kk) 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