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 qqgyp at 2011-05-14 22:41:19 on Problem 3587
#include <stdio.h>
#include <math.h>
const double esp=1e-9;

int n;
double point[660][2];
double dis[660][660];

int main()
{
	int n;
	int i, j, k;
	double ans, temp;
	double a, b, c;
	double p;

	scanf("%d", &n);
	while (n--> 0)
	{
		scanf("%d", &n);
		ans = 0.0;
		for (i = 0; i < n; i++)
		{
			scanf("%lf%lf", &point[i][0], &point[i][1]);
		}
		for (i = 0; i < n; i++)
		{
			for (j = i + 1; j < n; j++)
			{
				dis[i][j] = sqrt((point[i][0]-point[j][0])*(point[i][0]-point[j][0])+(point[i][1]-point[j][1])*(point[i][1]-point[j][1]));
			}
		}
		for (i = 0; i < n; i++)
		{
			for (j = i + 1; j < n; j++)
			{
				for (k = j + 1; k < n; k++)
				{
					if(dis[i][j]<=esp||dis[i][k]<=esp||dis[j][k]<=esp)break;
					if(fabs(dis[i][j]+dis[i][k]-dis[j][k])<esp)break;
					if(fabs(dis[i][j]+dis[j][k]-dis[i][k])<esp)break;
					if(fabs(dis[j][k]+dis[i][k]-dis[i][j])<esp)break;
					a = dis[i][j];
					b = dis[i][k];
					c = dis[j][k];
					p = (a+b+c)/2;
					temp = a*b*c/4/sqrt(p*(p-c)*(p-b)*(p-a));
					if (temp > ans)
					{
						ans = temp;
					}
				}
			}
		}
		printf("%.3lf\n", ans);
	}
	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