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

难道怎是rpwt,这样为什么会wa?

Posted by yujiashan at 2006-12-06 18:20:24 on Problem 1323
看不出来是哪里错了。
重新写了个没用排序的,就过了。
好诡异呀!  大牛帮看下。
//------------------------------------------
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
	return *(int*)b-*(int*)a;
}
int main()
{
	int m,n,p=0,a[51],b[1001];
	while(scanf("%d%d",&m,&n)&&m!=0&&n!=0)
	{
		p++;
		for(int i=n*(m-1);i<=m*n;i++)
			b[i]=true;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			b[a[i]]=false;
		}
        qsort(a,n,sizeof(a[0]),cmp);
		int j,k=0;
		for(i=0;i<n;i++)
		{
			if(a[i]<=n*(m-1))
				break;
			for(j=a[i]+1;j<=m*n;j++)
			{
				if(b[j])
				{
					b[j]=false;
					break;
				}
			}
			if(j==m*n+1)
				k++;
		}
		printf("Case %d: %d\n",p,k);
	}
	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