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. NYOJ2括号配对问题

    括号配对是最基本的栈的问题,它是栈入门的经典题目,思路是,如果是左括号直接进栈,如果是右括号,这时就要比较栈顶的元素与他是否匹配,如果匹配则出栈,否则进栈,下面是代码的实现: #include < ...

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

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

  3. jsp引入struts标签,引入自己写的jquery需要注意的问题

    1.使用struts2标签的时候在jsp页面开头引入这句话: <%@ taglib prefix="s" uri="/struts-tags"%> ...

  4. public static <T> Map<String, T> json2map

    /** * json string convert to map with javaBean */ public static <T> Map<String, T> json2 ...

  5. 抓取锁的sql语句-第五次修改

    CREATE OR REPLACE PROCEDURE SOLVE_LOCK AS V_SQL VARCHAR2(3000); --定义 v_sql 接受抓取锁的sql语句V_SQL02 VARCHA ...

  6. 【USACO 2.4.3】牛的旅行

    [描述] 农民 John的农场里有很多牧区.有的路径连接一些特定的牧区.一片所有连通的牧区称为一个牧场.但是就目前而言,你能看到至少有两个牧区通过任何路径都不连通.这样,Farmer John就有多个 ...

  7. 外边距叠加collapsing-margin

    原载:Smallni | http://www.smallni.com/collapsing-margin/ 恩,margin叠加一直是个问题,也是我们一直会遇到的问题,很久以前就想把这个知识点整理下 ...

  8. Python datetime time 常用操作

    测试版本: Python 2.7 获取当前时间的两种方法 import datetime,time now = time.strftime("%Y-%m-%d %H:%M:%S") ...

  9. Gson解析json繁杂数据

    碰到json数据.里面格式众多.list+string[]+等等.具体json参数如下: eg:以下为接口参数: "responseData":{ "brandCode& ...

  10. 关于InstallShield Projects[转]

    关于   InstallShield   Projects:         InstallShield   可以创建三种类型的项目(Project)     1.InstallScript   Pr ...