【HDOJ】1071 The area

数学题,先求抛物线和直线的系数,再利用积分公式求面积。

 1 #include <stdio.h>
 2 #include <math.h>
 3 
 4 int main() {
 5     double x1, x2, x3, y1, y2, y3;
 6     double a, b, c, k, m;
 7     double s1, s2;
 8     int case_n;
 9 
10     scanf("%d", &case_n);
11 
12     while (case_n--) {
13         scanf("%lf%lf%lf%lf%lf%lf", &x1,&y1, &x2,&y2, &x3,&y3);
14         a = (y2-y1) / pow(x2-x1, 2);
15         b = -2*a*x1;
16         c = a*x1*x1+y1;
17         k = (y2-y3) / (x2-x3);
18         m = y3 - k*x3;
19         s1 = a*pow(x2, 3)/3 + (b-k)*x2*x2/2 + (c-m)*x2;
20         s2 = a*pow(x3, 3)/3 + (b-k)*x3*x3/2 + (c-m)*x3;
21         printf("%.2lf\n", s2-s1);
22     }
23 
24     return 0;
25 }

 

posted on 2014-04-01 17:04  Bombe  阅读(124)  评论(0编辑  收藏  举报

导航