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

Re:帮帮我看看

Posted by myi_i at 2004-10-26 19:37:16 on Problem 1944
In Reply To:Re:帮帮我看看 Posted by:ync at 2004-10-26 19:11:16
你那个不对是因为
测这个
5 2
1 5
2 5
那我这个不对,为什么啊
#include"stdio.h"
main()
{
	int n,p,x,y,i,j,min,max;
	int barn[1000];
		while(scanf("%d%d",&n,&p)!=EOF)
		{
			for(i=0;i<1000;i++)
				barn[i]=0;

			for(j=0;j<p;j++)
			{
				scanf("%d%d",&x,&y);
				max=x;min=y;
				if(max<min)
				{max=y;min=x;}
				
				if(max-min>min+n-max)
				{
					for(i=max;i<min+n;i++)
						barn[i%n]=1;
				}
				else
				{
					for(i=min;i<max;i++)
						barn[i%n]=1;
				}
			}		
			j=0;
			for(i=0;i<1000;i++)
				if(barn[i]==1)
					j++;
			printf("%d\n",j);
		}
}

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