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; }
相关文章推荐
- 携程第二场预赛 1003:位图像素的颜色(水题,判断点是否在矩形内)
- jquery ajax应用中iframe自适应高度问题解决方法
- javascript事件冒泡详解和捕获、阻止方法
- java 装饰器模式
- Chapter 2 unit 1 of Bootstrap-Bootstrap CSS
- c++ 父类指针转换为子类指针后调用子类的成员函数问题
- STM32的GPIO使用的函数剖析
- Linux平台从文件中查找字符赋值于变量
- Ackerman函数
- linux内核分析--中断的分类
- 后缀表达式
- 运行java遇到的常见问题
- 线程的共享资源和私有资源
- 移动计算为王——我眼中的下一代计算机产业
- 程序员岁月的那些碎片记忆
- js 笔记 定时器
- 最长公共子序列打印路径
- 移动计算为王——我眼中的下一代计算机产业
- Android自定义 Dialog 对话框
- VC-socket通信