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

各位大牛 麻烦帮挑下错~

Posted by zainantest at 2007-09-27 16:18:14 on Problem 1323
#include<stdio.h>
int flag[1001];
int main()
{
	int m,n,i,j,temp,count,l=0;
	for(i=0;i<1001;i++)
	{
		flag[i]=0;
	}
	while(1)
	{
		l++;
	    scanf("%d%d",&m,&n);
		if(m==0&&n==0)
			break;
		for(i=0;i<n;i++)
		{
			scanf("%d",&temp);
			flag[temp]=1;
		}
		count=0;
		for(i=m*n;i>0;i--)
		{
			if(flag[i]==1)
			{
				count++;
			}
			else if(flag[i]==0)
			{
				for(j=i-1;j>0;j--)
				{
					if(flag[j]==1)
					{
						flag[j]=2;
						break;
					}
				}
				if(j<=0)
					break;
			}
		}
		printf("Case %d: %d\n",l,count);
	}
	return 0;
}
同样的算法 count 从n减就对了。。。

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