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包含: 创建一个 ...
随机推荐
- nodejs安装遇到npm命令无法使用问题
解决方法: 在用户文件夹中建立npm文件夹就可以使用了. 再使用npm命令就可以了.
- 阿里云服务器下安装LAMP环境(CentOS Linux 6.3)
http://ninghao.net/course/514 http://www.sphinxsearch.org/archives/243 ctrl + l putty 清理屏幕 apache 自 ...
- 转 消息队列之 RabbitMQ
转 https://www.jianshu.com/p/79ca08116d57 消息队列之 RabbitMQ 预流 2017.05.06 16:03* 字数 4884 阅读 80990评论 18喜欢 ...
- LVS-nat模式-原理介绍
集群,为解决某个特定问题将多台计算机组合起来形成的单个系统 lvs-nat: 本质是多目标IP的DNAT,通过将请求报文中的目标地址和目标端口修改为某挑出的RS的RIP和PORT实现转发 lvs集群类 ...
- GoF23种设计模式之行为型模式之策略模式
传送门 ☞ 轮子的专栏 ☞ 转载请注明 ☞ http://blog.csdn.net/leverage_1229 1概述 定义一系列算法,把它们一个个都封装起来,并且让它们可以相互 ...
- DP刷题记录(长期更新)
bzoj 2748 一个吉他手,有一个初始音量,有一个音量最大值max. 给定n个音量变化量,从第一个变化量开始,可以选择加上或者减去变化量.途中音量不能低于0,不能超过max. 求最后能达到的最大音 ...
- MIP启发式算法:Variable Neighborhood Decomposition Search
*本文记录和分享学习到的知识,算不上原创. *参考文献见链接. 本文主要简述和VND VNS RINS很相关的vairable neighborhood decomposition search. 目 ...
- 持续化集成Jenkins的系统配置
最近在研究selenium2自动化测试,用到持续化集成jenkins.由于之前仅限于使用,而没有真正动手配置过,所以现在学习从零开始,搭建持续化集成,故而有了这篇博客. 先介绍一下项目持续集成测试,这 ...
- luogu1208 尼克的任务
倒着推就是了 #include <iostream> #include <cstdio> #include <vector> using namespace std ...
- [解读REST] 0.REST 相关参考资料
Web之父 Tim Berners Lee :https://en.wikipedia.org/wiki/Tim_Berners-Lee 世界上诞生的第一个网站:http://info.cern.ch ...