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. 克隆选择算法-python实现

    CSAIndividual.py import numpy as np import ObjFunction class CSAIndividual: ''' individual of clone ...

  2. NOI题库--砝码称重V2(多重背包2^n拆分)

    以前只会写多重背包的原版,渣的不行,为了做此题不得不学习了一下,发现其实也不难,只要理解了方法就好多了(PS:其实和倍增挺像的) 8756:砝码称重V2 总时间限制: 1000ms 内存限制: 655 ...

  3. [NOIP2011] 普及组

    数字反转 小模拟 #include<cstdio> #include<iostream> #include<cstring> using namespace std ...

  4. java获取每个月的最后一天

    package timeUtil; import java.text.SimpleDateFormat; import java.util.Calendar; public class LastDay ...

  5. Android 设计模式 之 单例模式

    http://blog.csdn.net/fangchongbory/article/details/7734199   目录(?)[+] 单例模式常见情景 首先实现1中的单例模式A 实现2中单例模式 ...

  6. knockoutjs + easyui.treegrid 可编辑的自定义绑定插件

    http://blog.csdn.net/maddemon/article/details/16846183 目前仅支持URL的CRUD.不需要的话可以却掉相关代码,把treegrid的data直接赋 ...

  7. CSS------添加注释框

    my.html <div><a href="#" class="tip">你好<span><k>哈哈哈哈< ...

  8. 51nod 1170 1770 数数字(动态规划)

    解题思路:看到题后,直接想到分成两种情况: ①:a*b >9 这里又分成两种 1. n==1 a*b 直接是一个两位数 求得十位和个位(这里十位和个位不可能相等) 然后如果等于d 则结果=1 2 ...

  9. mappedBy reference an unknown target entity property解决方法

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error ...

  10. 【一个iOS官方文档错误】关于keyWindow是否可以接受触摸事件?

    [一个iOS文档错误]关于keyWindow是否可以接受触摸事件?   关于keyWindow,官方文档有一个解释: 同一时间只有一个window可以成为keyWindow,keyWindow可以接受 ...