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. 用python实现简单的数字信号软件滤波处理

    做嵌入式开发,经常需要通过逻辑分析仪对数字信号进行数据分析.如果信号源附近有强干扰源,并且逻辑分析仪滤波效果不好的话,获取到的数字信号,经常带有一些"毛刺",这些"毛刺& ...

  2. 一步步带你做vue后台管理框架(二)——上手使用

    系列教程<一步步带你做vue后台管理框架>第二课 github地址:vue-framework-wz 线上体验地址:立即体验 闲扯再多不会用也没白搭,这节课我来带大家直接上手框架,体验到简 ...

  3. pycharm远程linux开发和调试代码

    pycharm是一个非常强大的python开发工具,现在很多代码最终在线上跑的环境都是linux,而开发环境可能还是windows下开发,这就需要经常在linux上进行调试,或者在linux对代码进行 ...

  4. Push or Pull?

    采用Pull模型还是Push模型是很多中间件都会面临的一个问题.消息中间件.配置管理中心等都会需要考虑Client和Server之间的交互采用哪种模型: 服务端主动推送数据给客户端? 客户端主动从服务 ...

  5. 微信公众平台接口调用第一步(获取access_token)

    最近公司需要开发微信公众号,闲着无聊就写写博客,希望能帮到你我 上代码: package test; import java.util.List; import java.util.ArrayList ...

  6. 个人作业3—个人总结(Alpha阶段)

    一.个人总结 在Alpha阶段,我们团队通过合作的方式,完成了之前觉得不大可能会完成的事(至少在我看来是这样的),大家其实之前的写代码能力都不太好,这期间大家都是边学边做,边做边学,最后跌跌撞撞的完成 ...

  7. 团队作业9--测试与发布(Beta版)

    Beta版本测试报告 1.在测试过程中总共发现了多少Bug?每个类别的Bug分别为多少个? a. 修复的bug: 写入SD存储卡文件权限问题 页面正确跳转 及 部分页面闪退的问题 b. 不能重现的bu ...

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

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

  9. 201521123077 《Java程序设计》第11周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 线程的同步(加锁防止多个线程同时访问) synchronized关键字修饰 可以使用于方法前或者方法内做同步 ...

  10. 201521123035《Java程序设计》第十四周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自 ...