HDU_1071——积分求面积,抛物线顶点公式
2013-07-17 16:48
316 查看
[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.
![](http://acm.hdu.edu.cn/data/images/1071_1.bmp)
[align=left]Input[/align]
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).
[align=left]Output[/align]
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
[align=left]Sample Input[/align]
2
5.000000 5.000000
0.000000 0.000000
10.000000 0.000000
10.000000 10.000000
1.000000 1.000000
14.000000 8.222222
[align=left]Sample Output[/align]
33.33
40.69
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.
![](http://acm.hdu.edu.cn/data/images/1071_1.bmp)
[align=left]Input[/align]
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).
[align=left]Output[/align]
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
[align=left]Sample Input[/align]
2
5.000000 5.000000
0.000000 0.000000
10.000000 0.000000
10.000000 10.000000
1.000000 1.000000
14.000000 8.222222
[align=left]Sample Output[/align]
33.33
40.69
/* 看图直接能看出来这是X-区域,X-区域的积分公式是 b Q2(x) ∫ dx∫ 1*dy a Q1(x) 先对y积分,然后对y积分,y的积分上下限是两个函数 /* 由图可知 a=x2 b=x3 Q1(x)=过p1,p2两点的直线方程 Q2(x)=抛物线方程 */ /* 我尼玛把抛物线顶点公式给忘了- -白活了 顶点 (h,b) 抛物线 y=a(x-h)^2+b 所以Q2(x)=((y2-y1)/(x2-x1)^2)*(x-x1)^2+y1 Q1(x)=(y3-y2)/(x3-x2)*x+y2-(y3-y2)/(x3-x2)*x2 */ #include <cstdio> int main() { int n; double x1,y1,x2,y2,x3,y3; scanf("%d",&n); while(n--) { scanf("%lf%lf",&x1,&y1); scanf("%lf%lf",&x2,&y2); scanf("%lf%lf",&x3,&y3); double a=(y2-y1)/((x2-x1)*(x2-x1)); double b=-2*a*x1; double c=a*x1*x1+y1; //这个数据浪费了我40分钟,艹 double k=(y3-y2)/(x3-x2); double t=y2-k*x2; // x3 // s=∫ Q2(x)-Q1(x) dx // x2 double s=a/3*(x3*x3*x3-x2*x2*x2)+(c-t)*(x3-x2)+0.5*(b-k)*(x3*x3-x2*x2); printf("%.2lf\n",s); } return 0; }
相关文章推荐
- HDU 1071 The area && 抛物线与直线积分面积
- hdu 1071 the area 用积分求面积
- HDU 1071 The area(数学 抛物线 积分)
- hdu 1071 The area(定积分求面积)
- YT14-HDU-求抛物线与直线间的面积(积分)
- HDU 1071(2013.9.21周赛A题:抛物线面积)
- HDU 1071 The area(抛物线与直线围成的面积)
- HDU 1071 The area (定积分求面积)
- Hdu 1071 The area (抛物线 简单定积分)
- 其中包括求给定点凸包顶点,凸包周长,凸包面积,自然也包括一些几何公式如求给定点围成图形面积和叉积等
- HDU-不定积分-求一条直线与抛物线所围成的面积
- HDU 5826(水题,物理公式推导,积分公式推导直接出结果)
- 求抛物线直线相交面积题(Problem ID:1071)
- hdu 1724 辛普森积分公式
- hdu 1071 The area 高斯消元求二次函数+辛普森积分
- 1071 The area 求面积(积分)
- HDU 1724 辛普森积分公式
- hdu-1071-The area-简单积分
- HDU 1724 Ellipse (simpson公式,求积分)
- hdoj1071积分求面积