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 zsc09_leaf at 2010-08-17 22:48:02 on Problem 2242
In Reply To:这道题,偶用解析几何过的,求两条直线垂直平分线的交点,即为圆心,然后求半径.看了大家的帖子,学习!!!!!! Posted by:Ontheline at 2009-02-18 12:18:43
我用这个办法发现精度远远不够啊


我的代码,精度不够


#include<iostream>
#include<cmath>
using namespace std;
const long double PI=3.141592653589793;
int main()
{
	double x1,x2,x3,y1,y2,y3;
	 while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF)
	 {
		 long double k1=-(x2-x1)/(y2-y1);
		 long double k2=-(x3-x2)/(y3-y2);
		 long double p1x=(x1+x2)/2,p1y=(y1+y2)/2,p2x=(x2+x3)/2,p2y=(y2+y3)/2;
		 long double b1=p1y-k1*p1x,b2=p2y-k2*p2x;
		 long double x=(b1-b2)/(k1-k2),y=k1*x+b1;
		 long double r=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
		 long double ans=PI*2.0*r;
		  printf("%.2lf\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