zoukankan      html  css  js  c++  java
  • HDU 1071 The area 平面几何

    题目大意:   如图,给定途中p1,p2,p3的点的 坐标,求阴影部分的面积。           

    解题报告:分别解出抛物线和直线的方程,然后对(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
  • 相关阅读:
    java源码--ArrayList
    java源码--AbstractList
    java中public protected friendly private作用域
    设置springmvc全局异常
    Java
    Java
    Java
    Java
    Java
    Java
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3117933.html
Copyright © 2011-2022 走看看