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.

InputThe 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). 
OutputFor 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.

数学 几何

定积分真™美妙,美得我都看哭了。

二次函数顶点式f(x)=a(x-h)^2+c  一次函数y=kx+b

然后求一波定积分,面积就出来了。

刚开始我用f(x)=ax^2+bx+c求定积分,三项化简快哭了,然后换成顶点式,又算了好久。

看了题解才意识到可以算[0,x3]的定积分,减去[0,x2]的。 而我之前的是[x2,x3],怪不得超麻烦……

花了一晚上终于搞出来了。

 /*by SilverN*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
double a,h,c,k,b;
double x1,x2,x3,y1,y2,y3;
double f(double x){
return a*x*x*x/+c*x+x*a*h*h-a*h*x*x - ( k*x*x/+b*x);
//二次函数定积分 //一次函数求梯形面积
}
int main(){
int T,i,j;
scanf("%d",&T);
while(T--){
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a=(y2-y1)/(x2-x1)/(x2-x1);
c=y1;
h=x1;
k=(y3-y2)/(x3-x2);
b=y2-k*x2;
printf("%.2f\n",f(x3)-f(x2));
}
return ;
}

HDU1071 The area的更多相关文章

  1. HDU1071 The area 【积分】

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

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

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

  3. [转]NopCommerce How to add a menu item into the administration area from a plugin

    本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...

  4. ASP.NET MVC系列:Area

    1. Area简介 ASP.NET MVC Area机制构建项目,可以将相对独立的功能模块切割划分,降低项目的耦合度. 2. Area设置Routing 新建Admin Area后,自动创建Admin ...

  5. Web API项目中使用Area对业务进行分类管理

    在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加 ...

  6. MVC View中获取action、controller、area名称

    获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...

  7. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  8. 如何在Linux上使用文件作为内存交换区(Swap Area)

    交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...

  9. MVC 添加Area

    在MVC项目中经常会使用到Area来分开不同的模块让项目结构更加的清晰. 步骤如下: 项目 –> 添加 -> 区域 ( Area ) 输入 Admin 添加成功后 Area包含: 创建一个 ...

随机推荐

  1. PAT (Basic Level) Practise (中文)-1019. 数字黑洞 (20)

    http://www.patest.cn/contests/pat-b-practise/1019 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第 ...

  2. 01_1_Struts环境搭建

    01_1_Struts环境搭建 1. MyEclipse配置部分 1.1创建项目 新建new—>Project—>Web Project—>Project Name(配置项目名)—& ...

  3. 类扩展Extension

    延展(Extension):在本类里声明私有方法. 1:延展定义的方法是在implemetation中. 2:声明的方法是私有方法. 3:延展中声明的方法可以不实现. #import "Ho ...

  4. 你对CommonJS规范了解多少?

    写在前面 为什么会出现CommonJS规范? 因为JavaScript本身并没有模块的概念,不支持封闭的作用域和依赖管理,传统的文件引入方式又会污染变量,甚至文件引入的先后顺序都会影响整个项目的运行. ...

  5. [JZOJ] 5837.Omeed

    先摆出来这个式子 \[ score=A\sum S_i+B\sum S_i\times f(i) \] 先研究\(f\)函数(也就是Combo函数) 显然的有 \[ f(i)=P_i(f(i-1)+1 ...

  6. spdlog&rapidjson 使用记录

    项目中需要记录log以及读写json,对比后选择了spdlog以及rapidjson. SPDLog 对于log只是要求能够记录到文件中以及能够过滤,选择spdlog是因为这个只需要包含头文件即可使用 ...

  7. 有关Kali更新问题的解决方法。

    近期更新源遭遇诸多不顺,无非是各种依赖问题的报错夹杂着各种稀奇古怪的问题,不过既然是玩Linux,就要做好处理各种疑难杂症的准备.经过了这几天的不断尝试,今天终于解决了更新出错的问题. 本人更新源出现 ...

  8. Html5_css

    CSS 在标签上设置style属性: background-color: #2459a2; height: 48px; ... 编写css样式: 1. 标签的style属性 2. 写在head里面 s ...

  9. 在Unix系统上,从源文件、目标文件、可执行文件的编译过程

    是由“编译器驱动”(compiler driver)完成的: unix> gcc -o hello hello.c 在这里,gcc的编译器驱动程序读取源文件hello.c, #include & ...

  10. 笔记-python-实用-程序运算时间计算

    方法1 import datetime starttime = datetime.datetime.now() #long running endtime = datetime.datetime.no ...