传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1071

The area

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12095    Accepted Submission(s): 8490

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
 
题目意思:
告诉你三个点,有一个点抛物线顶点,问你这三个点在抛物线中确定的面积
 
分析:
设抛物线y=a(x-b)^2+c   p1总是抛物线的顶点
    所以根据p1和另外随便一个点我们可以确定抛物线方程中的所有参数
    直线方程y=kx+d;
    抛物线方程减去直线方程的积分就是二者形成的面积
    面积就是a(x-b)^2+c-kx-d的积分
 
code:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
double a,b,c,k,d;
double f(double x)//积分
{
return a*x*x*x/-(*a*b+k)*x*x/+(a*b*b+c-d)*x;
}
int main()
{
/*
设抛物线y=a(x-b)^2+c p1总是抛物线的顶点
直线方程y=kx+d;
面积就是a(x-b)^2+c-kx-d的积分
*/
double x1,y1,x2,y2,x3,y3;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
c=y1;
b=x1;
a=(y2-c)/((x2-b)*(x2-b));
k=(y3-y2)/((x3-x2));
d=y2-k*x2;
printf("%0.2lf\n",f(x3)-f(x2));
}
return ;
}
 

HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)的更多相关文章

  1. Agent J(求三个圆围成的区域面积)

    A - A Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status P ...

  2. HDU - 1071 - The area - 高斯约旦消元法 - 自适应辛普森法积分

    http://acm.hdu.edu.cn/showproblem.php?pid=1071 解一个给定三个点的坐标二次函数某区域的积分值. 设出方程之后高斯消元得到二次函数.然后再消元得到直线. 两 ...

  3. HDU 1071 - The area

    求曲线和直线围成的面积 求表达式,求积分 #include <iostream> using namespace std; ],y[]; int t; double k,m;//fx1: ...

  4. HDU 1071 The area (数学定积分)

    题意:求阴影部分面积. 析:没什么可说的,就是一个普通的定积分. 代码如下: #include <cstdio> #include <iostream> using names ...

  5. HDU 1071 The area ——微积分

    [题目分析] 求二次函数和一次函数围成的面积. 先解方程求出一次函数和二次函数. 然后积分. 现在还是不会积分. [代码] #include <cstdio> #include <c ...

  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. HDU 6625 three arrays 求两个序列异或最小值的排列(一个可以推广的正解

    目录 题意: 解析 原题描述 字典树动态求Mex @(hdu 6625求两个序列异或最小值的排列) 题意: \(T(100)\)组,每组两个长度为\(n(100000)\)的排列,你可以将\(a[]\ ...

  8. 25.按要求编写一个Java应用程序: (1)编写一个矩形类Rect,包含: 两个属性:矩形的宽width;矩形的高height。 两个构造方法: 1.一个带有两个参数的构造方法,用于将width和height属性初化; 2.一个不带参数的构造方法,将矩形初始化为宽和高都为10。 两个方法: 求矩形面积的方法area() 求矩形周长的方法perimeter() (2)通过继承Rect类编写一个具有

    package zhongqiuzuoye; //自己写的方法 public class Rect { public double width; public double height; Rect( ...

  9. Hdu 1358 Period (KMP 求最小循环节)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1358 题目描述: 给出一个字符串S,输出S的前缀能表达成Ak的所有情况,每种情况输出前缀的结束位置和 ...

随机推荐

  1. SpringBoot | 第三十一章:MongoDB的集成和使用

    前言 上一章节,简单讲解了如何集成Spring-data-jpa.本章节,我们来看看如何集成NoSQL的Mongodb.mongodb是最早热门非关系数据库的之一,使用也比较普遍.最适合来存储一些非结 ...

  2. C++程序设计基础(3)条件语句和循环语句

    注:读<程序员面试笔记>笔记总结 1.知识点 1.1条件语句 (1)if……:(2)if……else……:(3)if……else if……:(4)switch(){case ():brea ...

  3. 强哥的分享--如何使用Spring Boot做一个邮件系统

    http://springboot.fun/ actuator是单机.集群环境下要使用Spring Boot Admin将各个单机的actuator集成越来 mvn clean package -Dm ...

  4. Java判断文件、文件夹是否存在

    在完成工作室任务的时候多次遇到这个问题,这是一个常用的知识点,记录如下: 1.判断文件是否存在,不存在则创建文件 File file=new File("C:\\2.jpg"); ...

  5. 嵌入式Tomcat Web服务器的使用

    在运行web工程时,常常要频繁启动tomcat,使用嵌入式tomcat可以减少部分重复操作. 1.下载tomcat5.0.28embed.zip 解压文件夹复制到工程下. http://archive ...

  6. JUnit测试框架的使用

    1.学习Junit框架的使用 可通过以下两个示例进行学习. A.Junit使用方法示例1 1)把Junit引入当前项目库中 新建一个 Java 工程—coolJUnit,打开项目coolJUnit 的 ...

  7. mysql六:mysql内置功能(视图、触发器、事务、存储过程、函数)

    一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 通过使用视图可以把查询过程中的 ...

  8. SQLAlchemy的使用---外键ForeignKey数据增删改查

    # 添加数据 from sqlalchemy.orm import sessionmaker from create_table_ForeignKey import engine, Student, ...

  9. Topcoder SRM 698 Div1 250 RepeatString(dp)

    题意 [题目链接]这怎么发链接啊..... Sol 枚举一个断点,然后类似于LIS一样dp一波 这个边界条件有点迷啊..fst了两遍... #include<bits/stdc++.h> ...

  10. js实现图片延时加载的原理

    实现原理: 附:(http://www.cnblogs.com/fishtreeyu/archive/2011/03/12/1982067.html) 把所有需要延时加载的图片改成如下的格式: < ...