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. [2017-07-18]ELK安装笔记

    ELK ElasticSearch LogStash Kibana Server:CentOS 7 采用RPM导入官方源方式进行安装 rpm --import https://artifacts.el ...

  2. hashMap遍历方式

    package Ch17; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java ...

  3. Vuejs 页面的区域化与组件封装

    组件的好处 当我用vue写页面的时候,大量的数据页面渲染,引入组件简化主页面的代码量,当代码区域块代码差不多相同时,组件封装会更加简化代码.组件是Vue.js最强大的功能之一. 组件可以扩展HTML元 ...

  4. springboot 入门三- 读取配置信息二(读取属性文件方式)

    在上篇文章中简单介绍自带读取方式.springboot提供多种方式来读取 一.@ConfigurationProperties(value="my") 支持更灵活的绑定及元数据的支 ...

  5. webpack2学习日志

    webpack说容易也容易,说难也难,主要还是看个人,想学到什么样的程度,很多公司可能要求仅仅是会用就行,但是也有一些公司要求比较高,要懂一些底层的原理,所以还是要花一些时间的,看个人需求.这篇仅仅是 ...

  6. 201521123084 《Java程序设计》第6周学习总结

    1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰,内容覆盖 ...

  7. 201521123035《Java程序设计》第七周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 参考资料: XMind 2. 书面作业 1.ArrayList代码分析 1.1 解释ArrayList的contains源代 ...

  8. 201521123078《java程序设计》第四次总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 继承是面向对象最显著的一个特性.继承是从已有的类中派生出新的类,新的类能吸收已有类的数据属性 ...

  9. 04面向对象编程-02-原型继承 和 ES6的class继承

    1.原型继承 在上一篇中,我们提到,JS中原型继承的本质,实际上就是 "将构造函数的原型对象,指向由另一个构造函数创建的实例". 这里,我们就原型继承的概念,再进行详细的理解.首先 ...

  10. 工作总结--如何定位web系统前后台的bug,以及bug分析/测试感想

    对于web项目前台和后台bug定位分析:一. 系统整体了解 懒企鹅营销服务平台用的架构:web前端: Bootstrap 3.0 组件丰富,兼容性好,界面美观 Server端: jsp+Servlet ...