TZOJ 1210 The area(微积分)
描述
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(微积分)的更多相关文章
- HDU 1071 The area ——微积分
[题目分析] 求二次函数和一次函数围成的面积. 先解方程求出一次函数和二次函数. 然后积分. 现在还是不会积分. [代码] #include <cstdio> #include <c ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- The area (hdu1071)积分求面积
The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- [LeetCode] 850. Rectangle Area II 矩形面积之二
We are given a list of (axis-aligned) rectangles. Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...
- [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 ...
- [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 ...
- [ZJU 1010] Area
ZOJ Problem Set - 1010 Area Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Jer ...
- [转]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 ...
随机推荐
- otter使用
参考网址:https://github.com/alibaba/otter/wiki/QuickStart 参考网址: https://www.aliyun.com/jiaocheng/1127326 ...
- APP-1-相关介绍及资料
一年前研究了下MUI框架,也做了一些简单的功能,将整个过程整理下.. 1.Hbuilder官网 http://www.dcloud.io/ 2.MUI前端框架 http://www.dcloud.io ...
- vue:绑定数据的vue页面加载会闪烁问题
1:在挂在数据的容器加上属性 v-cloak 2:在css中添加如下代码 但有时候还是会不起作用,可能原因有两个 2.1:display属性被更高权限的display属性覆盖了,我们增加权限就好了 2 ...
- ACM__搜素之BFS与DFS
BFS(Breadth_First_Search) DFS(Depth_First_Search) 拿图来说 BFS过程,以1为根节点,1与2,3相连,找到了2,3,继续搜2,2与4,相连,找到了4, ...
- Linux命令:history
显示历史(执行过的)命令. history [n] history -c history -d offset history -anrw [filename] history -p arg [arg ...
- Servlet之ServletContext获取web上下文路径、全局参数、和Attribute(域)
1)获取web上下文路径 public void doGet(HttpServletRequest request, HttpServletResponse response) throws Serv ...
- Java复习 之容器
小生快要准备找工作了 现在开始复习一下Java基础之容器 Set和List是一个个往里面存 Map是两个两个往里面装 所谓重复指的是他们互相equals Collection 接口定义了存取一组对象的 ...
- IIS8.0 部署WCF Services
今天在Win 8的IIS上部署WCF Services,访问SVC文件时出现找不到处理程序的错误,以前遇到这个问题时都是尝试通过注册asp.net的方式处理一下,但是在Win8下这招不灵了,出现如下提 ...
- 关于那个.get .post .ajax ztree 还有后台servlet传递数据
servlet给前台传递data串 用的方法是 PrintWriter out = response.getWriter(); // response.sendRedirect("test. ...
- 新书预告 ArcGIS跨平台开发系列第一本
新书预告 ArcGIS跨平台开发系列第一本 候选题目: ArcGIS Runtime开发实验实习教程 ArcGIS Runtime开发案例教程 简介: GIS最新现代开发理念打造的跨所有移动和桌面平台 ...