Problem 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
上源代码:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int n;
double x1,y1,x2,y2,x3,y3;
double a,b,c,k,m,sum1,sum2;
cin>>n;
while(n--)
{
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=(y2-y1)/pow((x2-x1),2);
b=-2*a*x1;
c=y1+a*x1*x1;
k=(y3-y2)/(x3-x2);
m=y3-k*x3;
sum1=a*pow(x3,3)*1.0/3+(b-k)*pow(x3,2)*1.0/2+(c-m)*x3;
sum2=a*pow(x2,3)*1.0/3+(b-k)*pow(x2,2)*1.0/2+(c-m)*x2;
cout<<fixed<<setprecision(2)<<(sum1-sum2)<<endl;
}
return 0;
}
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
33.33 40.69
计算抛物线与直线围成区域的面积
这道题目要求求解一个由抛物线和一条直线围成的区域面积。输入包含多组测试用例,每组用例给出三个交点坐标,包括抛物线顶点P1和另外两个交点P2、P3,坐标值范围在0.0到1000.0之间。你需要计算并输出每组测试用例的面积,结果保留两位小数。
415

被折叠的 条评论
为什么被折叠?



