首页 技术 正文
技术 2022年11月12日
0 收藏 936 点赞 3,061 浏览 1867 个字

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.

The area  积分积分 

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

25.000000 5.0000000.000000 0.00000010.000000 0.00000010.000000 10.0000001.000000 1.00000014.000000 8.222222  

Sample Output

33.3340.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));
}
}

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291