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 athenaa at 2011-03-21 15:34:19 on Problem 3349
In Reply To:此题数据有问题 不需要考虑位置也能过 Posted by:563150913 at 2011-03-04 16:03:52
#include<stdio.h>
#include<algorithm>
#include<map>

using namespace std;

map<__int64,bool>hash;

__int64 change(__int64 a[])
{
	__int64 temp=0,i;
	for(i=0;i<6;i++)
		temp=temp*10+a[i];
	return temp;
}

int main()
{
	__int64 a[6],i,n,j;
	bool flag=false;
	while(scanf("%I64d",&n)!=EOF)
	{
		hash.clear();
		for(i=0;i<n;i++)
		{
			for(j=0;j<6;j++)
				scanf("%I64d",&a[j]);
			if(!flag)
			{
				sort(a,a+6);
				__int64 temp=change(a);
				printf("%I64d\n",temp);
				if(!hash[temp])
					hash[temp]=true;
				else
					flag=true;
			}
		}
		if(flag)
			printf("Twin snowflakes found.\n");
		else
			printf("No two snowflakes are alike.\n");
	}
	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