HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)
传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=1071
The area
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12095 Accepted Submission(s): 8490
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.

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).
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
Hint
For float may be not accurate enough, please use double instead of float.
Author
Ignatius.L
题目意思:
告诉你三个点,有一个点抛物线顶点,问你这三个点在抛物线中确定的面积
分析:
设抛物线y=a(x-b)^2+c p1总是抛物线的顶点
所以根据p1和另外随便一个点我们可以确定抛物线方程中的所有参数
直线方程y=kx+d;
直线方程y=kx+d;
抛物线方程减去直线方程的积分就是二者形成的面积
面积就是a(x-b)^2+c-kx-d的积分
面积就是a(x-b)^2+c-kx-d的积分
code:
#include<bits/stdc++.h> using namespace std; typedef long long LL; double a,b,c,k,d; double f(double x)//积分 { return a*x*x*x/3-(2*a*b+k)*x*x/2+(a*b*b+c-d)*x; } int main() { /* 设抛物线y=a(x-b)^2+c p1总是抛物线的顶点 直线方程y=kx+d; 面积就是a(x-b)^2+c-kx-d的积分 */ double x1,y1,x2,y2,x3,y3; int t; scanf("%d",&t); while(t--) { scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3); c=y1; b=x1; a=(y2-c)/((x2-b)*(x2-b)); k=(y3-y2)/((x3-x2)); d=y2-k*x2; printf("%0.2lf\n",f(x3)-f(x2)); } return 0; }
心之所向,素履以往
分类:
ACM
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南