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. 简单的邮件发送mail.jar

    public class MailSender { final static Logger logger = Logger.getLogger(MailSender.class); /** * 发送简 ...

  2. cocos2dx lua 吞噬层的触摸事件

    首先要创建一个layer,设置该层为可触摸 layer:setTouchEnabled(true) 注册触摸事件 local listener = cc.EventListenerTouchOneBy ...

  3. 当c++遇上音乐

    运用到的函数 #include <windows.h> Beep( f, t ); Sleep( t ); eep() 函数可以让蜂鸣器发出频率为f赫兹,音长大约为 2t 毫秒的音.(注意 ...

  4. CentOS7练习

    为编译安装的httpd服务,实现service unit文件破解centos7 口令修改默认的启动内核为新编译内核启动时临时禁用SELinux启动时进入emergency模式卸载编译安装的新内核

  5. GTX 750等低配显卡如何玩转Deepfakes?

    这里说的Deepfakes软件还是DeepFaceLab,人工智能换脸,是使用深度学习方法来实现的.而深度学习程序对电脑配置要求是非常高的,尤其是跑模型这个环节.很多低配电脑,根本就跑步起来.比如像G ...

  6. Can Japan stand up to US request to contain China?

    From Global Times Two days before US President Donald Trump's visit to Japan, A fake news story caug ...

  7. Java多线程之Deque与LinkedBlockingDeque深入分析

    有大小的队列就叫有界队列 如 ArrayBlockingquue, 反之是无界队列 如 LinkedBlockingDeque. 单词写错了.  是的,LinkedBlockingDeque 永远满不 ...

  8. AOP面向切面编程笔记

    1.AOP概念:Aspect Oriented Programming 面向切面编程 2.作用:本质上来说是一种简化代码的方式 继承机制 封装方法 动态代理 …… 3.情景举例 ①数学计算器接口[Ma ...

  9. POJ:3228-Gold Transportation(要求最小生成树最大边最小)

    Gold Transportation Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3079 Accepted: 1101 D ...

  10. Linux学习-什么是 X Window System

    Unix Like 操作系统不是只能进行服务器的架设而已,在美编.排版.制图.多媒体应用上也是有其 需要的. 这些需求都需要用到图形接口 (Graphical User Interface, GUI) ...