The area
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6004 Accepted Submission(s): 4193
Note: The point P1 in the picture is the vertex of the parabola.

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).
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.69HintFor float may be not accurate enough, please use double instead of float.
====================================
直线方程:y=kx+b
抛物线方程:一般式:y=ax^2+bx+c
顶点式:y=a(x-h)^2+c
两方程相减做积分
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int t;double x0,x1,x2,y0,y1,y2,k,b,h,c,a,s;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2);
k=(y2-y1)/(x2-x1);
b=y1-k*x1;
h=x0;
c=y0;
a=(y1-c)/((x1-h)*(x1-h));
s=a/3*((x2-h)*(x2-h)*(x2-h)-(x1-h)*(x1-h)*(x1-h))+c*(x2-x1)-k/2*(x2*x2-x1*x1)-b*(x2-x1);
printf("%.2lf\n",s);
}
return 0;
}
5021



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



