题目大意:   如图,给定途中p1,p2,p3的点的 坐标,求阴影部分的面积。        HDU 1071 The area 平面几何   

解题报告:分别解出抛物线和直线的方程,然后对(a*x^2+b*x+c)-kx-m积分,范围是p2到p3,公式看代码。

 1 #include<cstdio>
 2 #include<cmath>
 3 int main( ) {
 4     int T;
 5     double x1,y1,x2,y2,x3,y3,a,b,c,k,m;
 6     while(scanf("%d",&T)!=EOF) {
 7         while(T--) {
 8             scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
 9             a=b=c=k=m=0;
10             if(x3!=x2&&x1!=x2)
11             b=1.0*(((x2*x2-x1*x1)/(x3*x3-x2*x2))*(y3-y2)-y2+y1)/((x2*x2-x1*x1)/(x3+x2)-x2+x1);
12             if(x1!=x2)
13             a=1.0*(y2-y1-b*(x2-x1))/(x2*x2-x1*x1);
14             c=1.0*y1-a*x1*x1-b*x1;
15             if(x3!=x2)
16             k=1.0*(y3-y2)/(x3-x2);
17             m=1.0*y2-k*x2;
18             
19             double sum1=(a/3.0)*x2*x2*x2+((b-k)/2.0)*x2*x2+(c-m)*x2;
20             double sum2=(a/3.0)*x3*x3*x3+((b-k)/2.0)*x3*x3+(c-m)*x3;
21             printf("%.2lf\n",sum2-sum1);
22         } 
23     }
24     return 0;
25 }
View Code

相关文章:

  • 2022-01-22
  • 2022-01-11
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2021-12-27
  • 2021-05-20
猜你喜欢
  • 2021-09-20
  • 2021-04-20
  • 2021-09-26
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案