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 12061058 at 2013-04-12 00:37:43 on Problem 1002
#include<iostream>
using namespace std;
int comp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int truu(char s[])
{
	int sum=0;
	int k=0;
	char c;
	for(int i=0;k<7;i++)
	{
		if(s[i]>='0' && s[i]<='9')
		{
			sum*=10;
			sum+=s[i]-'0';
			k++;
		}
		else if(s[i]>='A' && s[i]<='Z')
		{
			sum*=10;
			c=s[i];
			if (c == 'A' || c == 'B' || c == 'C') c = '2';
			if (c == 'D' || c == 'E' || c == 'F') c = '3';
			if (c == 'G' || c == 'H' || c == 'I') c = '4';
			if (c == 'J' || c == 'K' || c == 'L') c = '5';
			if (c == 'M' || c == 'N' || c == 'O') c = '6';
			if (c == 'P' || c == 'R' || c == 'S') c = '7';
			if (c == 'T' || c == 'U' || c == 'V') c = '8';
			if (c == 'W' || c == 'X' || c == 'Y') c = '9';
			sum+=c-'0';
			k++;
		}
	}
	return sum;
}
int save[100000];
int main()
{
	int i,j,n,sum;
	char s[200];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s;
		save[i]=truu(s);
	}
	qsort(save,n,sizeof(int),comp);
	sum=0;
	for(j=1,i=0;i<n;i++)
	{
		while(save[i]==save[i+1])
		{
			j++;
			i++;
		}
		if(j>1)
		{
			cout<<save[i]/10000<<'-'<<save[i]-(save[i]/10000)*10000<<' '<<j<<endl;
			j=1;
			sum=1;
		}
	}
	if(sum==0)
		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