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

请各位高手指点迷津,为什么是wrong answer?

Posted by xiaoyaowangchao at 2006-08-11 19:08:52 on Problem 1323
#include<stdio.h>
void main()
{
	int m,n,i,j,k1,k2,min,res ;
	int count = 0 ;
	while(1)
	{
		int data[2000] = {0} ;
		res = 0 ;
		count++ ;
		scanf("%d%d",&m,&n) ;
		if(m==0&&n==0)
			break ;
		scanf("%d",&min) ;
		data[min] = 1 ;
		for( i = 1 ; i < n ; i++ )
		{
			scanf("%d",&k1) ;
			if( min > k1)
				min = k1 ;
			data[k1] = 1 ;
		}
		k1 = 0 ; k2 = 0 ;
		i = m*n ;
		while(1)
		{
			for( j = i ; data[j]==0 ; j-- )
				k2++ ;
			for( i = j ; data[i]==1&&i>=min; i-- )
				k1++ ;
			if(i<min)
			{
				if(k1>k2)
					res += k1-k2 ;
				break ;
			}
			
			if(k1>k2)
			{
				res += k1-k2 ;
				k1=k2=0 ;
			}
		}
		printf("case %d:%d\n",count,res) ;

	}
}





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