描述

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 a random point on the parabola, and
P2, P3 are the intersectant points. Any two points of P1, P2 and P3 are
not coincidence each other.

输入

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).

输出

For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.

样例输入

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

样例输出

33.33
40.69

提示

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

题意

题意很简单,给你抛物线上三个点,p2和p3是线上的点,保证三点不共线,求上图红线画出的面积

题解

抛物线设y=ax^2+bx+c,把三个点代入公式,化简可得a,b,c

直线设y=a1x+b1,a1为斜率,易得b1

然后求积分∫(x2,x3)  ax2+bx+c-a1x-b1

可得[1/3*ax3+1/2*bx2+cx-1/2*a1x2-b1x](x2,x3)  ==  [1/3*ax33+1/2*bx32+cx3-1/2*a1x32-b1x3]-[1/3*ax23+1/2*bx22+cx2-1/2*a1x22-b1x2] 即为答案

代码

 #include<bits/stdc++.h>
using namespace std; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
double x1,y1,x2,y2,x3,y3,a1,b1,a,b,c,ans;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a1=(y3-y2)/(x3-x2);
b1=y3-a1*x3;
a=((y3-y1)-a1*(x3-x1))/((x3*x3-x1*x1)-(x3+x2)*(x3-x1));
b=((y3-y2)-a*(x3*x3-x2*x2))/(x3-x2);
c=y3-a*x3*x3-b*x3;
ans=((1.0/)*a*x3*x3*x3+0.5*(b-a1)*x3*x3+(c-b1)*x3)-((1.0/)*a*x2*x2*x2+0.5*(b-a1)*x2*x2+(c-b1)*x2);
printf("%.2f\n",ans);
}
return ;
}

TZOJ 1210 The area(微积分)的更多相关文章

  1. HDU 1071 The area ——微积分

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

  2. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  3. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  4. The area (hdu1071)积分求面积

    The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  5. [LeetCode] 850. Rectangle Area II 矩形面积之二

    We are given a list of (axis-aligned) rectangles.  Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...

  6. [LeetCode] 892. Surface Area of 3D Shapes 三维物体的表面积

    On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cu ...

  7. [LeetCode] 883. Projection Area of 3D Shapes 三维物体的投影面积

    On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes. Each ...

  8. [ZJU 1010] Area

    ZOJ Problem Set - 1010 Area Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Jer ...

  9. [转]NopCommerce How to add a menu item into the administration area from a plugin

    本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...

随机推荐

  1. Java基础之用记事本编辑java代码运行,并且打成jar包后运行

    使用记事本写java代码 1.在d盘新建一个记事本,名字叫做zhanzhuang.java,会询问不可用,是否继续,点击是 2.在里面编辑就如下内容,注意文件的名字要和 class 后面的名字相对应 ...

  2. 尚硅谷redis学习8-事务

    是什么? 能干嘛? 常用命令 案例说明 1.正常执行 2.放弃事务 3.全部放弃(全体连坐) 4.只抛弃错误(冤头债主) 5.watch监控 悲观锁 悲观锁(Pessimistic Lock), 顾名 ...

  3. [CI]CodeIgniter特性 & 结构

    ------------------------------------------------------------------------------------------------- 市场 ...

  4. Linux下MySQL5.7.18二进制包安装(手动添加配置文件my_default.cnf)

    本文出处:http://www.cnblogs.com/wy123/p/6815049.html 最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5. ...

  5. eclipse 访问GitHub 问题

  6. Mac中opencv批量对图片进行二值化

    对灰度图像进行二值化,传入的图片是手写汉字的截图,通过二值化把字的部分提出来.用ostu进行二值化 #include <stdio.h> #include <iostream> ...

  7. OCR技术浅探(转)

    网址:https://spaces.ac.cn/archives/3785 OCR技术浅探 作为OCR系统的第一步,特征提取是希望找出图像中候选的文字区域特征,以便我们在第二步进行文字定位和第三步进行 ...

  8. Linux安装face_recgnition

    Ubuntu 3:apt-get install python3.6-dev 4:pip3 install face_recgnition 5:  pip3 install opencv-python ...

  9. 微信小程序---picker

    picker 从底部弹起的滚动选择器,现支持五种选择器,通过mode来区分,分别是普通选择器,多列选择器,时间选择器,日期选择器,省市区选择器,默认是普通选择器. wxml: 普通选择器(mode = ...

  10. git gitlab 使用 提交代码解决冲突

    1.更改完代码后,git push 发生错误 注: 此时,使用 git pull: 更新代码,git 会自动merge不同的更新, a.  如果git 自动merge成功,再进行 git push操作 ...