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
 /*
看图直接能看出来这是X-区域,X-区域的积分公式是
b Q2(x)
∫ dx∫ 1*dy
a Q1(x)
先对y积分,然后对y积分,y的积分上下限是两个函数
/*
由图可知
a=x2
b=x3
Q1(x)=过p1,p2两点的直线方程
Q2(x)=抛物线方程
*/
/*
我尼玛把抛物线顶点公式给忘了- -白活了
顶点 (h,b) 抛物线 y=a(x-h)^2+b
所以Q2(x)=((y2-y1)/(x2-x1)^2)*(x-x1)^2+y1
Q1(x)=(y3-y2)/(x3-x2)*x+y2-(y3-y2)/(x3-x2)*x2
*/
#include <cstdio>
int main()
{
int n;
double x1,y1,x2,y2,x3,y3;
scanf("%d",&n);
while(n--)
{
scanf("%lf%lf",&x1,&y1);
scanf("%lf%lf",&x2,&y2);
scanf("%lf%lf",&x3,&y3);
double a=(y2-y1)/((x2-x1)*(x2-x1));
double b=-*a*x1;
double c=a*x1*x1+y1; //这个数据浪费了我40分钟,艹
double k=(y3-y2)/(x3-x2);
double t=y2-k*x2;
// x3
// s=∫ Q2(x)-Q1(x) dx
// x2
double s=a/*(x3*x3*x3-x2*x2*x2)+(c-t)*(x3-x2)+0.5*(b-k)*(x3*x3-x2*x2);
printf("%.2lf\n",s);
}
return ;
}

HDU_1071——积分求面积,抛物线顶点公式的更多相关文章

  1. The area (hdu1071)积分求面积

    The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  2. bzoj1502 simpson求面积

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1502 题解: simpson积分求面积,s = (f(a)+f(b)+4*f(c))/6*Δx ...

  3. 牛客训练二:处女座的签到题(STL+精度+三角形求面积公式)

    题目链接:传送门 知识点: (1)三个点,三角形求面积公式 (2)精度问题: double 15-16位(参考文章) float 6-7位 long long 约20位 int 约10位 unsign ...

  4. Herding(hdu4709)三点运用行列式求面积

    Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  5. POJ 1408 Fishnet【枚举+线段相交+叉积求面积】

    题目: http://poj.org/problem?id=1408 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  6. poj 3348--Cows(凸包求面积)

    链接:http://poj.org/problem?id=3348 Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions:  ...

  7. P - Atlantis - hdu1542(求面积)

    题意:rt 求面积......不计算重复面积(废话..)hdu1255 的弱化版,应该先做这道题在做那道题的. ******************************************** ...

  8. 编写一个矩形类,私有数据成员为矩形的长( len)和宽(wid),wid设置为0,有参构造函数设置和的值,另外,类还包括矩形的周长、求面积、取矩形的长度、取矩形的长度、取矩形的宽度、修改矩形的长度和宽度为对应的形参值等公用方法。

    class Rectangle { private double len, wid; public Rectangle()//求矩形周长 { len = 0; wid = 0; } public Re ...

  9. HDU - 1255 覆盖的面积 (线段树求面积交)

    https://cn.vjudge.net/problem/HDU-1255 题意 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. 分析 求面积并的题:https://www.cnbl ...

随机推荐

  1. svcutil 生成代理类时的问题

    如果有这个的xsd, group内嵌choice的结构: <xs:complexType name="CreateType">        <xs:sequen ...

  2. XML 序列化与PULL解析

    简介 Pull解析XML XmlPullParser解析器的运行方式与SAX解析器相似.它提供了类似的事件(开始元素和结束元素),但需要使用parser.next()方法来提取它们.事件将作为数值代码 ...

  3. noip 2012 国王游戏(贪心+高精)

    /* 我是不会说我考试的时候想到了正解却把金币取大看成金币求和的.... 觉得只按左右手乘积排序不太对 有反例 也可能我反例放到这个题里是错的吧 按自己的理解排的序 就是各种讨论... 假设 第i个人 ...

  4. [转载]使用兼容ie6 ie7 ie8 FF的text-overflow:ellips

    使用兼容ie6 ie7 ie8 FF的text-overflow:ellipsis超出文本显示省略号来代替截取函数更有利于seo,如果使用截取函数,源代码中的标题是显示不完整的,即便是在title属性 ...

  5. mssql sql高效关联子查询的update 批量更新

    /* 使用带关联子查询的Update更新     --1.创建测试表 create TABLE Table1     (     a varchar(10),     b varchar(10),   ...

  6. [转] NSString / NSMutableString 字符串处理,常用代码

     原文 :  http://justcoding.iteye.com/blog/1405951 Objective-C 中核心处理字符串的类是 NSString 与 NSMutableString , ...

  7. xcode升级插件失效修复

    每次xcode升级以后,插件都会失效.可以通过一行命令解决这个问题. 摘自传人的博客 find ~/Library/Application\ Support/Developer/Shared/Xcod ...

  8. http请求的cookie

    Cookie的作用: Cookie是用于维持服务端会话状态的,通常由服务端写入,在后续请求中,供服务端读取. HTTP请求,Cookie的使用过程 1.server通过HTTP Response中的& ...

  9. 如何遍历json属性和动态添加属性

    var person= { name: 'zhangsan', pass: '123' , 'sni.ni' : 'sss', hello:function (){ for(var i=0;i< ...

  10. FindBugs的Eclipse插件安装与使用

    1.FindBugs介绍 FindBugs是一款Java静态代码分析工具,与其他静态分析工具(如Checkstyle和PMD)不同,FindBugs 不注重样式或者格式,它专注于寻找真正的缺陷或者潜在 ...