HDU1071 The area
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的更多相关文章
- HDU1071 The area 【积分】
The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
- The area (hdu1071)积分求面积
The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- [转]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 ...
- ASP.NET MVC系列:Area
1. Area简介 ASP.NET MVC Area机制构建项目,可以将相对独立的功能模块切割划分,降低项目的耦合度. 2. Area设置Routing 新建Admin Area后,自动创建Admin ...
- Web API项目中使用Area对业务进行分类管理
在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加 ...
- MVC View中获取action、controller、area名称
获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- MVC 添加Area
在MVC项目中经常会使用到Area来分开不同的模块让项目结构更加的清晰. 步骤如下: 项目 –> 添加 -> 区域 ( Area ) 输入 Admin 添加成功后 Area包含: 创建一个 ...
随机推荐
- C#数组删除元素
一.C#数组删除元素 在C#中,只能在动态数组ArrayList类中对数组执行删除元素的操作.因为动态数组是一个可以改变数组长度和元素个数的数据类型. 示例: using System;using S ...
- NSRegularExpression 使用
需求: // 后台返回的某个实体 reminder = { cost = , type = , template = 可免费做某事{time}分钟,超过将按{cost}K元收费, time = } t ...
- leetcode-9-basic-binary search
278. First Bad Version You are a product manager and currently leading a team to develop a new produ ...
- 转:跟我一起写Makefile (PDF重制版)
原文地址:http://seisman.info/how-to-write-makefile.html 其它一些问题 不妨看一下:http://blog.csdn.net/huyansoft/art ...
- selenium2设置浏览器窗口
1.窗口最大化 //设置窗口最大化driver.manage().window().maximize(); 2.指定设置窗口大小 //指定呀设置窗口的宽度为:800,高度为600Dimension d ...
- 【报错】invalid or unexpected token
结果发现是把英文的,写成了中文字符,系统没法识别.
- net clr via c sharp chap1-- note
Tag-> 托管代码 Tag-> .NET Framework 系统环境检测 Tag-> 设置平台 Tag-> 查询64或32位机 Tag-> IL编译成机器指令 Tag ...
- loj2000 「SDOI2017」数字表格
there #include <iostream> #include <cstring> #include <cstdio> using namespace std ...
- 一个通用的分页存储过程实现-SqlServer(附上sql源码,一键执行即刻搭建运行环境)
使用前提 查询表必须有ID字段,且该字段不能重复,建议为自增主键 背景 如果使用ADO.NET进行开发,在查询分页数据的时候一般都是使用分页存储过程来实现的,本文提供一种通用的分页存储过程,只需要传入 ...
- 在从1到n的正数中1出现的次数 【微软面试100题 第三十题】
题目要求: 给定 一个十进制正整数N,写下从1开始,到N的所有整数,然后数一下其中出现的所有“1”的个数. 例如:N = 2,写下1,2.这样只出现了1个“1”. N = 12 ...