hdoj1071 The area(数学题,积分)

xiaoxiao2021-02-28  83

来源:http://acm.hdu.edu.cn/showproblem.php?pid=1071

y=ax*x+bx+c。给了你三个点,其中一个还是顶点,可以根据顶点和其他两点中的一点求出a,b,c的值。

在根据列出的积分式代入求解。

#include<stdio.h> #include<math.h> #include<string> #include<algorithm> using namespace std; int main() { int t; double x0,y0,x1,y1,x2,y2,a,b,c,s1,s2; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2); b=(y1-y0)/(x1-x1*x1/(2*x0)-x0/2); a=-b/(2*x0); c=y0-b*x0/2; s1=fabs(x1*x1*x1-x2*x2*x2)*a/3+fabs(x1*x1-x2*x2)*b/2+c*fabs(x1-x2); s2=(y1+y2)*fabs(x2-x1)/2; s1=fabs(s1-s2); printf("%.2lf\n",s1); } return 0; }

转载请注明原文地址: https://www.6miu.com/read-83352.html

最新回复(0)