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。。能想出来的数据都试过了,但是还是不行。。

Posted by xxqq5454 at 2014-03-31 12:58:19 on Problem 1002
#include <iostream>

using namespace std;

int main()
{
    char s[300];
    int i,j,n,l;
    short *a= new short [10000000];
	long sum=0,sum_w=1000000;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        for(l=0;s[l]!='\0';l++);
        for(j=0;j<l;j++)
            switch (s[j]) 
			{
				case '0':
					{
						sum_w/=10;
						break;
					}
				case '1':
					{
						sum+=1*sum_w;
						sum_w/=10;
						break;
					}
                case 'A':case 'B':case 'C':case '2':
					{
                	    sum+=2*sum_w;
						sum_w/=10;
                	    break;
                    }
				case 'D':case 'E':case 'F':case '3':
					{
						sum+=3*sum_w;
						sum_w/=10;
                	    break;
					}
				case 'G':case 'H':case 'I':case '4':
					{
						sum+=4*sum_w;
						sum_w/=10;
                	    break;	 
					}
				case 'J':case 'K':case 'L':case '5':
					{
						sum+=5*sum_w;
						sum_w/=10;
                 	   break;					
					}
				case 'M':case 'N':case 'O':case '6':
					{
						sum+=6*sum_w;
						sum_w/=10;
                	    break;										
					}
				case 'P':case 'R':case 'S':case '7':
					{
						sum+=7*sum_w;
						sum_w/=10;
               		    break;						
					}
				case 'T':case 'U':case 'V':case '8':
					{
						sum+=8*sum_w;
						sum_w/=10;
                    	break;						
					}
				case 'W':case 'X':case 'Y':case '9':
					{
						sum+=9*sum_w;
						sum_w/=10;
                 	    break;						
					}
                default:
                    break;
            }
		a[sum]++;
		sum=0;
		sum_w=1000000;
    }
    short judg=1;
    for (sum_w=0;sum_w<10000000;sum_w++)
		if (a[sum_w]>1) 
		{
			printf("%03d-%04d %d\n",sum_w/10000,sum_w%10000,a[sum_w]);
			judg=0;
		}
	if (judg==1) cout<<"No duplicates."<<endl;
	delete []a;
	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