hdu1071(积分求面积)
2013-05-16 21:57
337 查看
Problem Description
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)
Input
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).
Output
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
Sample Input
Sample Output
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)
Input
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).
Output
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
Sample Input
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
Sample Output
33.33 40.69
#include<stdio.h> #include<math.h> struct pint { double x,y; }node; int main() { double a,m,c,k,b,area,f; struct pint p[4]; int i,t; scanf("%d",&t); while(t--) { for(i=1;i<=3;i++) scanf("%lf%lf",&p[i].x,&p[i].y); k=(p[2].y-p[3].y)/(p[2].x-p[3].x);//直线方程为y=k*x+b; b=p[2].y-k*p[2].x; //抛物线的方程为y=a*x^2+m*x+c; a=((p[2].x-p[3].x)*(p[1].y-p[2].y)-(p[1].x-p[2].x)*(p[2].y-p[3].y)); a/=((p[1].x*p[1].x-p[2].x*p[2].x)*(p[2].x-p[3].x)-(p[2].x*p[2].x-p[3].x*p[3].x)*(p[1].x-p[2].x)); m=(p[1].y-p[2].y)/(p[1].x-p[2].x)-a*(p[1].x+p[2].x); c=p[1].y-a* p[1].x*p[1].x-m*p[1].x; area=a/3*pow(p[3].x,3.0)+(m-k)/2*pow(p[3].x,2.0)+(c-b)*p[3].x; area-=(a/3*pow(p[2].x,3.0)+(m-k)/2*pow(p[2].x,2.0)+(c-b)*p[2].x); printf("%.2lf\n",area); } return 0; }
相关文章推荐
- hdu1071(定积分求面积)
- The area (hdu1071)积分求面积
- hdu1071(积分求直线和抛物线构成的面积)
- The area (hdu1071)积分求面积
- hdu1071 (积分求面积)
- 数学积分求面积的 HDU1071The area
- hdu1071算面积问题
- bzoj 2178 圆的面积并【辛普森积分】
- SPOJ CIRU 圆的面积并 自适应辛普森积分
- hdu 1071 The area 高数积分求面积~~~~小水题~~
- YT14-HDU-求抛物线与直线间的面积(积分)
- [BZOJ 2178] 圆的面积并 【Simpson积分】
- 二次函数积分面积【数学】
- 定积分之旋转曲面的面积
- 用积分求椭圆的面积
- hdu1071(抛物线弓形面积阿基米德算法)
- hdu 1071 the area 用积分求面积
- bzoj 2178: 圆的面积并 (辛普森积分)
- HDU1071-抛物线积分
- [BZOJ]2178 圆的面积并 Simpson积分