HDU 1071 微积分

The area

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7611    Accepted Submission(s): 5332

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.

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

题意:

给3个点p1,p2,p3的坐标,求图中斜线覆盖部分。

思路:

设二次函数为y=a*x^2+b*x+c(1)。

由于p1为二次函数顶点,所以b=-2*a*x1 (2)代入二次函数式子 1 里得y=a*x^2-2*a*x1*x+c(3),把p1,p2坐标代入 3 中,算出a,然后由 2 算出b ,然后a、b、p3坐标代入 1 中算出c。这样下来就算出a、b、c了,那么ans=微积分求面积-梯形面积。

代码:

 1 #include <iostream>
 2 #include <string>
 3 #include <map>
 4 #include <stdio.h>
 5 #include <math.h>
 6 using namespace std;
 7 #define pi acos(-1)
 8
 9 double a, b, c;
10 double S(double x){
11     return a*x*x*x/3+b*x*x/2+c*x;
12 }
13
14 main()
15 {
16      int t;
17      double x1, y1, x2, y2, x3, y3;
18      double s;
19      cin>>t;
20      while(t--){
21          scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
22          a=(y2-y1)/(x2*x2-2*x1*x2+x1*x1);
23          b=-2*a*x1;
24          c=y3-a*x3*x3-b*x3;
25          s=S(x3)-S(x2)-(y2+y3)*(x3-x2)/2;
26          printf("%.2lf\n",s);
27      }
28 }

HDU 1071 微积分

时间: 2024-08-26 19:56:01

HDU 1071 微积分的相关文章

hdu 1071 The area 高斯消元求二次函数+辛普森积分

构造系数矩阵,高斯消元求解二次函数,然后两点式求直线函数,带入辛普森积分法无脑AC... #include<cstdio> #include<queue> #include<algorithm> #include<cstring> #include<vector> #include<cmath> using namespace std; struct node { double x,y; }p[4]; double g[10][10]

HDU 1071 The area ——微积分

[题目分析] 求二次函数和一次函数围成的面积. 先解方程求出一次函数和二次函数. 然后积分. 现在还是不会积分. [代码] #include <cstdio> #include <cstring> #include <cstdlib> //#include <cmath> #include <set> #include <map> #include <string> #include <algorithm> #

hdu 1071 - The area(解题报告)

The area Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8715    Accepted Submission(s): 6115 Problem Description Ignatius bought a land last week, but he didn't know the area of the land becau

HDU 1071 - The area

求曲线和直线围成的面积 求表达式,求积分 1 #include <iostream> 2 using namespace std; 3 double x[4],y[4]; 4 int t; 5 double k,m;//fx1: y=kx+m 6 double a,b,c;//fx2: y=a(x-b)^2+c 7 void getfx1() 8 { 9 k=(y[3]-y[2])/(x[3]-x[2]); 10 m=y[2]-k*x[2]; 11 } 12 void getfx2() 13

HDU 1071 The area (数学定积分)

题意:求阴影部分面积. 析:没什么可说的,就是一个普通的定积分. 代码如下: #include <cstdio> #include <iostream> using namespace std; int main(){ int T; cin >> T; double x0, y0, x1, y1, x2, y2, k, b, a, c, h, s; while(T--){ scanf("%lf %lf %lf %lf %lf %lf",&x0

hdu 1071 The area【定积分】

用顶点式\( a(x-h)^2+k=y \)解方程,转化为\(ax^2+bx+c=y \)的形式,然后对二次函数求定积分\( \frac{ax^3}{3}+\frac{bx^2}{2}+cx+C \)即可.(其实我不知道那个C是干什么用的反正这里不用加. #include<iostream> #include<cstdio> using namespace std; int T; double x1,x2,x3,y1,y2,y3,a,b,c,h,k; double f(double

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201