杭电ACM-The area

这道题目要求求解一个由抛物线和一条直线围成的区域面积。输入包含多组测试用例,每组用例给出三个交点坐标,包括抛物线顶点P1和另外两个交点P2、P3,坐标值范围在0.0到1000.0之间。你需要计算并输出每组测试用例的面积,结果保留两位小数。
部署运行你感兴趣的模型镜像

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;
}


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


您可能感兴趣的与本文相关的镜像

Qwen3-8B

Qwen3-8B

文本生成
Qwen3

Qwen3 是 Qwen 系列中的最新一代大型语言模型,提供了一整套密集型和专家混合(MoE)模型。基于广泛的训练,Qwen3 在推理、指令执行、代理能力和多语言支持方面取得了突破性进展

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值