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. An example usage of an encryption algorithm (AES, in this case) is:

    pycrypto 2.6.1 : Python Package Index An example usage of an encryption algorithm (AES, in this case ...

  2. 使用jdk的socket通信

    使用JDK提供的API进行网络通信,会用到Socket,ServerSocket两个类.写个简单的SERVER和CLIENT之间发消息的小程序,竟然发现了挺多的问题. 这是服务器端代码: packag ...

  3. HTML5开发桌面应用:选择node-webkit还是有道heX

    近几年,移动应用和web2.0大行其道,相比之下.传统桌面应用程序开发显得相对冷清(包含该领域技术人才的后继力量),但在一些场景下,它依旧有其不可替代的优势. 将HTML5和Node.JS的技术优势. ...

  4. CSS中float属性和clear属性的一些笔记

    在学习CSS的最后一部分内容中,float属性和clear属性比较难以用语言描述,因此在笔记本中无法准确的记录这两个属性的用法.所以在博客园上以图文的形式记录这两种属性的特征,以备以后查阅. 首先,定 ...

  5. gcc manual

    $ gcc --helpUsage: gcc [options] file...Options:  -pass-exit-codes         Exit with highest error c ...

  6. Find命令, find用法,

    Find命令 用法示例:查找HOME目录下大于1M小于10M的文件$ find ~ -size +1M -size -10M 15个小时这一时刻修改的文件:find . -mmin 900 | xar ...

  7. js获取并设置&lt;p&gt;&lt;/p&gt;的显示的值。

    原文链接:http://www.nowamagic.net/librarys/posts/jquery/23 html()方法 此方法类似于JavaScript中的innerHTML属性,能够用来读取 ...

  8. Cloud Foundry中通用service的集成

    目前,CloudFoundry已经集成了很多第三方的中间件服务,并且提供了用户添加自定义服务的接口.随着Cloud Foundry的发展,开发者势必会将更多的服务集成进Cloud Foundry,以供 ...

  9. mormort 土拨鼠,做后端服务那是杠杠的,基于http.sys

    http.sys你可以用 mormort 土拨鼠,做后端服务那是杠杠的,基于http.sys并且还是开源的,作者天天更新代码,非常勤奋,官方论坛提问,回答也快其实,稍微看看,就能玩的挺好的

  10. nginx 区分pc和mobile 到不同的404页面

    if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry|vivo)') { set $mobile_request '1'; } ...