您的位置:首页 > 其它

hdu 1071 The area

2014-04-12 10:40 381 查看

The area

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 7093 Accepted Submission(s): 4980



[align=left]Problem Description[/align]
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.



[align=left]Input[/align]
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).

[align=left]Output[/align]
For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.

[align=left]Sample Input[/align]

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


[align=left]Sample Output[/align]

33.33
40.69

Hint
For float may be not accurate enough, please use double instead of float.


[align=left]Author[/align]
Ignatius.L

[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 1021 1061 1108 1019 1049
小伙伴们一定对我的发博客速度感到吃惊了吧。。。
原因就是我的逗比队友昨天对我进行体力上的透支压迫,我硬是从18:30刷到了凌晨1:00
期间只吃了一份热水烫的羊肉泡馍,资产阶级就是这么压迫剥削工农阶级的


题目就是就二次曲线与一条线段所围封闭图形的面积
根据所给数据解出方程求积分即可
贴上我自认为很整洁的代码:
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define esp 1e-9
#define MAXN 10010
#define ll long long
#define INF 0x7FFFFFFF
#define BUG system("pause")
#define SW(a,b) a^=b;b^=a;a^=b;
using namespace std;
int main(void){
int n;
cin >> n;
while(n--){
double x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> x3 >> y3;
double a = (y2-y1)/((x2-x1)*(x2-x1));
double b = -2.0*a*x1;
double c = a*x1*x1+y1;
//		cout << "a = " << a << endl;
//		cout << "b = " << b << endl;
//		cout << "c = " << c << endl;
double math1 = a/3.0*x2*x2*x2+b/2.0*x2*x2+c*x2;
double math2 = a/3.0*x3*x3*x3+b/2.0*x3*x3+c*x3;
//		cout << math1 << endl;
//		cout << math2 << endl;
double angle = (fabs(y2)+fabs(y3))*(fabs(x3-x2))/2.0;
//		cout << "angle = " << angle << endl;
printf("%.2lf\n", fabs(fabs(math1-math2)-angle));
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: