hdu 1071 ACM steps The area

The area

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.


 
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


      
      
Hint
For float may be not accurate enough, please use double instead of float.
 
Author
Ignatius.L



题目大意:求如图阴影部分面积。(数学水题)

首先看到题目啦,抛物线和直线相交,只求所围图形的面积。我们想到了啥呢?当然是化简计算啦!!!(会偷懒的人事半功倍~)

首先,推翻它的坐标系。以P2为原点,原x轴方向为正方向做平面直角坐标系。设抛物线:y = a x² + b x  。
  其次,把握顶点的对称。由对称轴为x₁有:b = -a x₁ 。带入(x₁,y₁)得:a = -y₁/x₁ b = 2 y₁/x₁ 。
  直观,积分得阴影面积。S =  ∫(x₂->0)(a x² + b x - y₂/x₂  x)dx  (计算时 y₂ 用x₁、y₁、x₂ 表示
最后,积分出来的时候是不是很激动呢?只用了简单的几个未知量呢~(斜眼笑)
S  =  y ₁  × x₂³ ÷ 6x ₁ ² (数学版 woc )= 1/6*y1*x2*x2*x2/x1/x1 (程序员版) 。

好吧,说到底就是一道积分水题喽,不要算错就好啦  ≡ ̄﹏ ̄≡ 

#include<stdio.h>
struct node
{
    double x,y;
};

double s(node a,node c)
{
    return a.y/a.x/a.x*c.x*c.x*c.x/6;//计算得公式。
}
int main()
{
    int n;
    node a,b,c;
    scanf("%d",&n);
    while(n--){
        scanf("%lf%lf",&a.x,&a.y);
        scanf("%lf%lf",&b.x,&b.y);
        scanf("%lf%lf",&c.x,&c.y);
        a.x-=b.x;a.y-=b.y;
        c.x-=b.x;c.y-=b.y;//新建坐标系。
        printf("%0.2lf\n",s(a,c));
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值