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

why wa 难道是斜率精度有问题?跪求高人指点

Posted by lqiaosh at 2008-12-23 21:42:22 on Problem 2606
#include <stdio.h>
struct x{
long	double xielu;
long	double y;
	int jishu;
}xie[20000];
struct y{
long	double x;
	int jishu;
}wuxielu[20000];

struct dian{
long	double x;
long	double y;
}jiedian[500];
int main()
{
	int n, i, j, k=0, k1=0, m, flag;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%llf%llf",&jiedian[i].x, &jiedian[i].y);
		//printf("%llf\n",jiedian[i].x);
		for(j=0; j<i; j++)
		{
			flag=1;
			if(jiedian[i].x==jiedian[j].x)
			{
				
				for(m=0; m<k; m++)
					if(jiedian[i].x==wuxielu[m].x)
					{
						wuxielu[m].jishu++;
						flag=0;
						goto loor;
					}
            	if(flag)
				{
					wuxielu[k].x=jiedian[i].x;
					wuxielu[k++].jishu++;
				}
			}
			else
			{
				double xielu=(jiedian[i].y-jiedian[j].y)/(jiedian[i].x-jiedian[j].x);
				double yj=(jiedian[j].y*jiedian[i].x-jiedian[i].y*jiedian[j].x)/
					(jiedian[i].x-jiedian[j].x);
				for(m=0; m<k1; m++)
					if((xielu==xie[m].xielu)&&(yj==xie[m].y))
					{	
						xie[m].jishu++;
					    flag=0;
					    goto loor;
					}
        if(flag)
				{
					xie[k1].y=yj;
					xie[k1].xielu=xielu;
					xie[k1++].jishu++;
				}
			}
	 	}
loor:1; 
	}
	int max=0;
	for(i=0; i<k1; i++)
	{
		if(xie[i].jishu>max)
			max=xie[i].jishu;
	}
	for(i=0; i<k; i++)
	{
		if(wuxielu[i].jishu>max)
			max=wuxielu[i].jishu;
	}
	printf("%d\n", max+1);

	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