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 imzhangliang at 2009-03-17 20:45:34 on Problem 1083
用的方法和zhujie一样, 错也是错在细小的地方

通常我都是用t做临时变量的,这回t又成了测试次数的变量,导致2个变量重用了。
但是用sample的数据刚好是所有的si < ti的,导致交换部分的变量t没有改变
                    
#include <stdio.h>

int main()
{
	int a[200];
	int n;
 	int i;
	int x,y;
	int t;
	int max;

	 scanf("%d",&t);
	 while(t-->0)
	 {
		 for(i=0;i<200;i++)
			 a[i]=0;

		 scanf("%d",&n);
		 while(n-->0)
		 {
		 	scanf("%d%d",&x,&y);

			x=(x-1)/2;
		 	y=(y-1)/2;
			 if(x>y)
			 {
				 int t;  /*开始没有加这个导致和上面的变量t重用了*/
				 t=x;
				 x=y;
				 y=t;
		 	}

		 	/*printf("x=%d,y=%d\n",x,y);*/

		 	for(i=x;i<=y;i++)
				a[i]++;
		 }

		 max=0;

		 for(i=0;i<200;i++)
			 if(max<a[i])
				 max=a[i];

		 printf("%d\n",max*10);
	 }
	 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