The area

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1637 Accepted Submission(s): 1298
 
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.

 
Author
Ignatius.L

求定积分公式

#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
using namespace std;
double a,b,c;
double f(double x)
{
return 1.0/*a*x*x*x+0.5*b*x*x+c*x;
}
int main()
{
double x1,y1,x2,y2,x3,y3;
int n;
cin>>n;
while(n--)
{
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=(y2-y1)/((x2-x1)*(x2-x1)); //顶点式求a
b=-*a*x1; //对称轴求b
c=y1-a*x1*x1-b*x1; //一般式求c
printf("%.2lf\n",f(x3)-f(x2)-(y3+y2)*(x3-x2)/); //定积分
}
return ;
}

HDU 2.1.7 (求定积分公式)的更多相关文章

  1. HDOJ1021题 Fibonacci Again 应用求模公式

    Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) ...

  2. C语言复习---矩形法求定积分函数

    一:分析: 大一学习积分的时候,我们学习过,可以通过矩形法来求定积分. 思路就是将积分区间划分成n等份,然后将这n等份近似看成矩形(或梯形),然后对所有的矩形(或梯形)的面积进行求和. 二:简单的例子 ...

  3. 牛客训练二:处女座的签到题(STL+精度+三角形求面积公式)

    题目链接:传送门 知识点: (1)三个点,三角形求面积公式 (2)精度问题: double 15-16位(参考文章) float 6-7位 long long 约20位 int 约10位 unsign ...

  4. matlab求定积分和不定积分

    matlab求定积分与不定积分 创建于2018-03-21 22:42 求定积分与不定积分是一件比较繁琐的事,但是我们可以借助matlab,下面与大家分享解决方法 材料/工具 matlab 求不定积分 ...

  5. YTU 2421: C语言习题 矩形法求定积分

    2421: C语言习题 矩形法求定积分 时间限制: 1 Sec  内存限制: 128 MB 提交: 354  解决: 234 题目描述 写一个用矩形法求定积分的通用函数,分别求 (说明: sin,co ...

  6. hdu 1071 The area【定积分】

    用顶点式\( a(x-h)^2+k=y \)解方程,转化为\(ax^2+bx+c=y \)的形式,然后对二次函数求定积分\( \frac{ax^3}{3}+\frac{bx^2}{2}+cx+C \) ...

  7. simpson公式求定积分(模板)

    #include<cstdio> #include<cmath> #include <algorithm> using namespace std; double ...

  8. HDU 1568 Fibonacci【求斐波那契数的前4位/递推式】

    Fibonacci Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Proble ...

  9. 题解报告:hdu 1124 Factorial(求N!尾数有多少个0。)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1124 Problem Description The most important part of a ...

随机推荐

  1. BZOJ-1002 轮状病毒 高精度加减+Kirchhoff矩阵数定理+递推

    1002: [FJOI2007]轮状病毒 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3543 Solved: 1953 [Submit][Statu ...

  2. 【poj3177】 Redundant Paths

    http://poj.org/problem?id=3177 (题目链接) 题意 给出一个n个节点m条边的无向图,求最少连几条边使图中没有桥. Solution 我们可以发现,用最少的边使得图中没有桥 ...

  3. 【bzoj3289】 Mato的文件管理

    http://www.lydsy.com/JudgeOnline/problem.php?id=3289 (题目链接) 题意 求区间逆序对 Solution 离线无修改查询,莫队转移:树状数组维护区间 ...

  4. 【poj1745】 Divisibility

    http://poj.org/problem?id=1745 (题目链接) 题意 给出n串数,可以在其两两之间添加+或-,判断是否存在某种方案使得出的表达式的答案可以整除k. Solution 水题一 ...

  5. java + jquery + ajax + json 交互

    前端js部分: $.ajax({ async:true, cache:false, type:"POST", dataType : 'json', url:"/shopp ...

  6. jquery中datagrid中getSelected和getSelections的应用

    http://blog.sina.com.cn/s/blog_8e50ede90101fff9.html 刚开始使用jquery的datagrid就知道如果要对特定的一行进行编辑,可以是 $('#on ...

  7. Java_观察者模式(Observable和Observer)

    http://blog.csdn.net/tianjf0514/article/details/7475164/ 一.观察者模式介绍 在Java中通过Observable类和Observer接口实现了 ...

  8. Effective Java之避免创建不必要的对象

    Effective Java中有很多值得注意的技巧,今天我刚开始看这本书,看到这一章的时候,我发现自己以前并没有理解什么是不必要的对象,所以拿出来跟大家探讨一下,避免以后犯不必要的错误! 首先书中对不 ...

  9. 织梦DedeCMS删除所有栏目或文章后,新建ID不从1开始的解决方法

    这个修改方法很简单,从模板无忧那里找到的,只需要在后台系统-SQL命令行工具里面运行以下语句即可,不用采用笨方法重新安装织梦CMS了. 删除所有栏目,新建ID从1开始: ALTER TABLE `de ...

  10. rwsr-sr-x类似权限设置

    如何设置suid/guid? 如果希望设置suid,那么就将相应的权限位之前的那一位设置为4:如果希望设置guid,那么就将相应的权限位之前的那一位设置为2:如果希望两者都置位,那么将相应的权限位之前 ...