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
  1. 2
  2. 5.000000 5.000000
  3. 0.000000 0.000000
  4. 10.000000 0.000000
  5. 10.000000 10.000000
  6. 1.000000 1.000000
  7. 14.000000 8.222222
 
Sample Output
  1. 33.33
  2. 40.69
Hint

For float may be not accurate enough, please use double instead of float.

 
Author
Ignatius.L

求定积分公式

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <math.h>
  6. using namespace std;
  7. double a,b,c;
  8. double f(double x)
  9. {
  10. return 1.0/*a*x*x*x+0.5*b*x*x+c*x;
  11. }
  12. int main()
  13. {
  14. double x1,y1,x2,y2,x3,y3;
  15. int n;
  16. cin>>n;
  17. while(n--)
  18. {
  19. cin>>x1>>y1>>x2>>y2>>x3>>y3;
  20. a=(y2-y1)/((x2-x1)*(x2-x1)); //顶点式求a
  21. b=-*a*x1; //对称轴求b
  22. c=y1-a*x1*x1-b*x1; //一般式求c
  23. printf("%.2lf\n",f(x3)-f(x2)-(y3+y2)*(x3-x2)/); //定积分
  24. }
  25. return ;
  26. }

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. 利用symbolsource/gitlink调试你的nuget包

    关键字: 如何调试Nuget下载的dll? VS  github  调试 参考文章: http://docs.nuget.org/create/creating-and-publishing-a-sy ...

  2. IOS基础之 (十五)知识点

    一 SEL 1. 方法的存储位置 每个类的方法地址列表都存储在类对象中. 每个方法都有一个与之对应的SEL类型的对象. 根据一个SEL对象就可以找到方法的地址,进而调用方法. Person.h #im ...

  3. HD 1011 Starship Troopers(树上的背包)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  4. HD1712ACboy needs your help(纯裸分组背包)

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  5. tmux下的滚屏

    先Ctrl+b进入tmux的操作模式,然后用PageUp和PageDown,

  6. c++标准库和stl关系

    C++标准库的所有头文件都没有扩展名.C++标准库的内容总共在50个标准头文件中定义,其中18个提供了C库的功能. <cname>形式的标准头文件[ <complex>例外]其 ...

  7. 织梦DedeCms网站更换域名后文章图片路径批量修改

    因为织梦上传图片用的是绝对地址,如果域名更换后,之前发布的文章的图片URL是不会跟着改变的,所以我们需要把旧域名替换成新的域名,方法很简单,有一段SQL语句更新一下文章正文内容就行. 复制下面SQL语 ...

  8. ASP.NET版Memcached监控工具(转载)

    在上一篇文章<使用Memcached提高.NET应用程序的性能>中周公讲述如何在.NET中使用Memcached来提高.NET应用程序的性 能.在实际的使用中有可能出现Memcached因 ...

  9. 最诡异的Linux fork进程问题(我们平时都在写)

    从来没有遇到过... 运行环境:在Linux自带的文本编辑器中输入C程序,在shell中编译运行,下面直接看代码和运行结果. 第一个代码:#include<stdio.h> #includ ...

  10. sql批量获取wordpress所有留言者的邮件地址

    如果你的wordpress博客有很多读者互动的话,他们的留言都会留下具体的联系邮箱,我们如何批量导出这些联系信息呢?可以试试下面的sql语句 SELECT DISTINCT comment_autho ...