链接:戳这里
The area
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
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.
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
Hint
For float may be not accurate enough, please use double instead of float.
题意:
给出一元二次方程的曲线以及一条直线的曲线算闭区间面积
思路:
积分搞搞
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
struct point{
double x,y;
point(double x=0,double y=0):x(x),y(y){}
};
double a,b,c,k,b1;
double getans(double x){
return a/3.0*x*x*x+0.5*(b-k)*x*x+(c-b1)*x;
}
int main(){
int T;
scanf("%d",&T);
while(T--){
point A,B,C;
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
a=(B.y-A.y)/((B.x-A.x)*(B.x-A.x));
b=-2.0*a*A.x;
c=A.y+b*b/(4.0*a);
k=(B.y-C.y)/(B.x-C.x);
b1=B.y-k*B.x;
double ans=getans(C.x)-getans(B.x);
printf("%.2f\n",ans);
}
return 0;
}