The area

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

Total Submission(s): 7476    Accepted Submission(s): 5222
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
Hint
For float may be not accurate enough, please use double instead of float.

题意:给定一个抛物线的顶点P1坐标和另外两点坐标P2、P3,以及一条穿过P2、P3的直线。求直线与抛物线围城的面积。

题解:每次做磊哥出的题总会学到些新东西。这次也不例外。这是我第一次做积分的题。高数总算是没白学。可是已知抛物线三点坐标求抛物线的方程我愣是没解出来,感觉太复杂了,在网上找的别人推出好的公式:

url=5T1k83zKP81FREbVbn3gBx0bF-AqBIEYoKwcA60fcMhZfVXng4twTqkBxgvOUo2ovkKpe3m2cabE9mgqvTZNva">click
here

#include <stdio.h>

int main()
{
int t;
double x1, y1, x2, y2, x3, y3, a, b, c, k, d, p, q, r, ans;
scanf("%d", &t);
while(t--){
scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
p = y1 / ((x1 - x2) * (x1 - x3));
q = y2 / ((x2 - x1) * (x2 - x3));
r = y3 / ((x3 - x1) * (x3 - x2));
a = p + q + r;
b = -p*(x2 + x3) - q*(x1 + x3) - r * (x1 + x2);
c = p * x2 * x3 + q * x1 * x3 + r * x1 * x2;
k = (y3 - y2) / (x3 - x2);
d = y2 - k * x2;
ans = (1.0/3*a*x3*x3*x3 + 1.0/2*(b-k)*x3*x3 + (c-d)*x3) -
(1.0/3*a*x2*x2*x2 + 1.0/2*(b-k)*x2*x2 + (c-d)*x2);
if(ans < 0) ans = -ans;
printf("%.2lf\n", ans);
}
return 0;
}

HDU1071 The area 【积分】的更多相关文章

  1. The area 积分积分

    The area Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  2. HDU1071 The area

    Ignatius bought a land last week, but he didn't know the area of the land because the land is enclos ...

  3. The area (hdu1071)积分求面积

    The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  4. HDU - 1071 - The area - 高斯约旦消元法 - 自适应辛普森法积分

    http://acm.hdu.edu.cn/showproblem.php?pid=1071 解一个给定三个点的坐标二次函数某区域的积分值. 设出方程之后高斯消元得到二次函数.然后再消元得到直线. 两 ...

  5. SPOJ CIRU The area of the union of circles ——Simpson积分

    [题目分析] 圆的面积并. 直接Simpson积分,(但是有计算几何的解法,留着flag). simpson积分,如果圆出现了不连续的情况,是很容易出事情的.(脑补一下) 但是没有什么办法,本来就是一 ...

  6. 杭电1071-The area

    问题描述:   Ignatius bought a land last week, but he didn't know the area of the land because the land i ...

  7. HDU_1071——积分求面积,抛物线顶点公式

    Problem Description Ignatius bought a land last week, but he didn't know the area of the land becaus ...

  8. hdu 5954 -- Do not pour out(积分+二分)

    题目链接 Problem Description You have got a cylindrical cup. Its bottom diameter is 2 units and its heig ...

  9. 【自适应辛普森积分】hdu1724 Ellipse

    Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

随机推荐

  1. hdu1114

    完全背包的水题,不过今天才学动态规划,就这样啦……hahahah!!! 完全背包跟普通背包的区别是普通背包从后往前循环,以防止被替换 完全背包是从前往后循环,后面的状态会跟着之前状态的改变而改变…… ...

  2. UVA11069 - A Graph Problem(DP)

    UVA11069 - A Graph Problem(DP) 题目链接 题目大意:给你n个点.要你找出有多少子串符合要求.首先没有连续的数字,其次不能再往里面加入不论什么的数字而不违反第一条要求. 解 ...

  3. dwz框架---(2)表单回调函数

    dwz中的表单回调函数大概有下面几种: /** * 普通ajax表单提交 * @param {Object} form * @param {Object} callback * @param {Str ...

  4. 新建表维护程序SM30

    1.先新建一个客制表 2.创建一个函数组 3.SE11中该表->实用程序->表维护生成器->权限组填写&NC& ->  函数组填写刚才创建的函数组->维护 ...

  5. (原创)(C#随笔)IEnumerable< ICollection < IList区别

    public interface IEnumerable { IEnumerator GetEnumerator(); } 再看ICollection<T> public interfac ...

  6. Android读取网络图片

    本文是自己学习所做笔记,欢迎转载,但请注明出处:http://blog.csdn.net/jesson20121020 在android4.0之后,已不同意在主线程中进行网络请求操作了, 否则会出现N ...

  7. Android学习-----如何使用sqlite对于后台数据交换,sqlite使用例程入门

     SQLite 这是一个非常流行的嵌入式数据库.它支持 SQL 查询,和只使用很少的内存.Android 在集成实施 SQLite,所以每 Android 应用程序能够使用 SQLite 数据库. ...

  8. Swift调用Objective-C编写的代码(颜色选择器KKColorListPicker调用)

    在Swift项目中,我们可以导入任意用Objective-C写的框架,代码库等.下面以Swift调用Objective-C编写的颜色选择器KKColorListPicker为例. 效果图如下:     ...

  9. DataReader和DataSet的区别以及使用

    DataReader和DataSet这两个对象都可以将检索的关系数据存储在内存中.它们在功能使用方面非常相似,但是它们不可以相互替换. 主要区别如表所示:   DataReader DataSet 数 ...

  10. touch修改文件的修改时间和访问时间,ls --full-time显示文件详细,stat命令

    1. 同时修改文件的修改时间和访问时间 touch -d "2010-05-31 08:10:30" test.doc 2. 只修改文件的修改时间 touch -m -d &quo ...