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. Qt4创建工程的几种方法:linux系统

    方法一:以Qt Creator 作为IDE 1.启动Qt Creator,并创建一个空项目 2.输入路径和工程名字 3.添加cpp文件 4.添加代码,并且编译执行 5.执行结果 方法二:利用linux ...

  2. LeetCode--Best Time to Buy and Sell Stock (贪心策略 or 动态规划)

    Best Time to Buy and Sell Stock Total Accepted: 14044 Total Submissions: 45572My Submissions Say you ...

  3. VC 实现视图区背景颜色渐变填充

    void CSTest1View::OnDraw(CDC* pDC) { CSTest1Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO:  ...

  4. Delphi的String内存结构(够清楚) good

    变量s的内存结构为(字符串编码)A8 03 (字符宽度)01 00 (引用计数)FF FF FF FF (字符串长度)0A 00 00 00 (实际内容)31 32 33 34 35 36 37 38 ...

  5. hadoop(六) - ZooKeeper安装与配置

    一. ZooKeeper配置 1.使用winscp上传zk安装包 zookeeper-3.4.5.tar.gz 2.解压安装包tar -zxvf zookeeper-3.4.5.tar.gz -C / ...

  6. UVA11324-- The Largest Clique(SCC+DP)

    题目链接 题意:给出一张有向图,求一个结点数最大的结点集,使得该结点集中随意两个结点u和v满足:要么u能够到到v,要么v能够到达u(u和v能够互相到达) 思路:我们能够缩点,用Tarjan求出全部强连 ...

  7. 地大邀请赛d

    Problem D: Tetrahedron Inequality Time Limit: 1 Sec   Memory Limit: 128 MB Submit: 15   Solved: 3 [ ...

  8. ASP.NET 常用内置对象详解-----Response

    利用提供的内置对象,可以实现页面之间的数据传递及实现一些特定的功能,如:缓冲输出,页面重定向等等. Response :响应,反应 Request:请求 Server:服务器 Application: ...

  9. Qt多线程(有详细例子)

    Qt线程类 Qt 包含下面一些线程相关的类:QThread 提供了开始一个新线程的方法QThreadStorage 提供逐线程数据存储QMutex  提供相互排斥的锁,或互斥量QMutexLocker ...

  10. hnnu 11546 Sum of f(x) (求一个数的全部约数和)

    代码: #include<cstdio> #include<cstring> #define N 200000 using namespace std; long long f ...