The area

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

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
 
 
 #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
struct point
{
double x,y;
} p1,p2,p3;
double a,b,c,a1,b1;
double F(double x)
{
return fabs(a*(x-b)*(x-b)+c-a1*x-b1);
}
void init()
{
b = p1.x;
c = p1.y;
a = (p2.y - c) / (p2.x - b) / (p2.x - b);
a1 = (p3.y - p2.y) / (p3.x - p2.x);
b1 = p2.y - a1 * p2.x;
//cout<<a<<" "<<b<<" "<<c<<" "<<a1<<" "<<b1<<" "<<endl;
}
//三点辛普森公式
double simpson(double width,double fa,double fb,double fc)
{
return (fb+fa+*fc)*width/;
} //自适应simpson公式递归过程
double asr(double a,double b,double eps,double A)
{
double c=(a+b)/;
double fa,fb,fc,L,R;
fa=F(a);
fb=F(b);
fc=F(c);
L=simpson(c-a,fa,fc,F((c+a)/));
R=simpson(b-c,fc,fb,F((b+c)/));
if(fabs(L+R-A)<=*eps) return L+R+(L+R-A)/;
return asr(a,c,eps/,L)+asr(c,b,eps/,R);
}
double asr1(double a,double b,double eps)
{
return asr(a,b,eps,simpson(b-a,F(a),F(b),F((b+a)/)));
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&p1.x,&p1.y);
scanf("%lf%lf",&p2.x,&p2.y);
scanf("%lf%lf",&p3.x,&p3.y);
init();
printf("%.2lf\n",asr1(p2.x,p3.x,0.0000001));
}
}
 
 

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. HDU - 1071 - The area - 高斯约旦消元法 - 自适应辛普森法积分

    http://acm.hdu.edu.cn/showproblem.php?pid=1071 解一个给定三个点的坐标二次函数某区域的积分值. 设出方程之后高斯消元得到二次函数.然后再消元得到直线. 两 ...

  4. SPOJ CIRU The area of the union of circles ——Simpson积分

    [题目分析] 圆的面积并. 直接Simpson积分,(但是有计算几何的解法,留着flag). simpson积分,如果圆出现了不连续的情况,是很容易出事情的.(脑补一下) 但是没有什么办法,本来就是一 ...

  5. hdu-5858 Hard problem(数学)

    题目链接: Hard problem Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Othe ...

  6. Monte Carlo 数值积分

    var amount = 0.0d; var hitTheTargetCount = 0.0d; var M = 2.0d; var rnd=new Random(); ; i < ; i++) ...

  7. LaTeX 中插入数学公式

    一.常用的数学符号 1.小写希腊字母 \alpha \nu \beta \xi \gamma o \delta \pi \epsilon \rho \zeta \sigma \eta \tau \th ...

  8. IOS内存泄漏

    1. . - (void)viewDidLoad { [superviewDidLoad]; self.view.frame=CGRectMake(, , , ); NSArray *title1=[ ...

  9. 用Javascript大批量收集网站数据

    最近为了写论文,要大批量收集慕课网的相关用户数据(因为用户个人主页是公开的),故而写了一个插件进行收集.需要在慕课网控制台输入.最后收集了3000多份数据. /* 收集项 收集标准 用户编号 慕课网用 ...

随机推荐

  1. 从服务器端获取列和数据动态创建Ext.grid.EditorGridPanel

    1.添加列的方法 var addColumn = function(){ this.fields = ''; this.columns = ''; this.addColumns=function(n ...

  2. HTML5新结构标签和移动端页面布局

    --------------------HTML5新结构标签--------------------1.h5新增的主要语义化标签如下: 1.header 页面头部.页眉 2.nav 页面导航 3.ar ...

  3. ABP从入门到精通(6):快速重命名解决方案

    SolutionRenamer SolutionRenamer 是一个解决方案快速重命名工具.经测试重命名一个全新asp.net zero core项目(ABP asp.net zero,.net c ...

  4. Oracle之range,hash,list分区现实应用及优缺点汇总

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp51 [align=center;] Oracle之range,hash,l ...

  5. [Unity 设计模式]桥接模式(BridgePattern)

    1.前言 继上一讲IOC模式的基础上继续本讲桥接模式,笔者感觉桥接模式是23种设计模式中桥接模式是最好用但也是最难理解的设计模式之一,23中设计模式就好武侠剧中一本武功秘籍,我们在工作过程中想要熟练运 ...

  6. outlook 无法搜索邮件的解决方法

    我的outlook版本是2007 SP3,英文版.一直有搜索不到邮件的问题,例如在搜索框输入发件人的名字,或者邮件中的词语,就是搜索不到邮件,即使那封邮件确实存在. 在网上搜索,Microsoft 的 ...

  7. main方法快速编辑日历

    public static void main(String[] args) { Scanner input=new Scanner (System.in); System.out.println(& ...

  8. wineshark分析抓取本地回环包

    wineshark分析抓取本地回环包 摘要 由于windows系统没有提供本地回环网络的接口,用Wireshark监控网络的话看不到localhost的流量.想要获取本地的网络数据包,可以通过一款小巧 ...

  9. 团队作业8——第二次项目冲刺(Beta阶段)5.21

    1.当天站立式会议照片 会议内容: 本次会议为第三次会议 本次会议在陆大楼2楼召开,本次会议内容: ①:检查总结第二次任务完成情况 ②:布置第三次任务的详细分工 ③:规定完成时间是在第四次任务之前 ④ ...

  10. 个人作业3--------个人总结(Alpha版本)

    1.问题 从第一次写博客开始,就开始意识到自己所犯的错误了,助教提醒命名规范的问题,还给了Java编码规范的链接,让自己以后能注意到这些问题. 对设计的需求分析需要团队一起,一开始分配任务是给个人分配 ...