您的位置:首页 > 其它

poj 1701【数学几何】

2013-11-04 22:55 302 查看

The area

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6524 Accepted Submission(s): 4578

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1071

[align=left]Problem Description[/align]
Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?

Note: The point P1 in the picture is the vertex of the parabola.

#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
int zong;
cin>>zong;
while(zong--)
{
double x1,y1,x2,y2,x3,y3;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
double t1=(x2*x2-x3*x3)*(y2-y1)-(x2*x2-x1*x1)*(y2-y3);
double t2=(x2*x2-x3*x3)*(x2-x1)-(x2*x2-x1*x1)*(x2-x3);
double b=t1/t2;
double a=(y2-y1-b*(x2-x1))/(x2*x2-x1*x1);
double c=y1-a*x1*x1-b*x1;
double k=(y2-y3)/(x2-x3);
double d=y2-k*x2;
double s1=1.0/3.0*a*(x3*x3*x3-x2*x2*x2)+1.0/2*b*(x3*x3-x2*x2)+c*(x3-x2);
double s2=(k*(x2+x3)+2*d)*(x3-x2)*1.0/2.0;
double s=s1-s2;
printf("%.2lf\n",s);
}
return 0;
}


View Code

[align=left] [/align]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: