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 ...
随机推荐
- URL分发(URLConf)
如果项目中应用太多,都写到顶层的urls.py中,如果个别应用url出问题的话,其他的应用也会受影响,所以我们需要对每个应用下面都写一个urls.py,实现分发 顶层urls.py中写:(属于blog ...
- js 正则函数初级之二
1. 小括号在正则中: 1.1 小括号:表示分组 1.2 分组之后,,每个组都有一个序号,从左到右,依次为1,2,3.......:可以使用 RegExp.$1,RegExp.$2,RegExp.$3 ...
- keal
I remember the wonderful moment you appeared before me, like a fleeting vision, like a genius of pur ...
- MyEclipse反向生成Java代码 ,Reverse Engineering-->Java Source Folder-->没有提供任何条目
在web项目名称上,手动执行一遍Add Hibernate Capabilities,然后再去DB Browser中进行反向生成pojo实体类和hbm.xml映射文件!,具体生成反向代码的配置如下图所 ...
- 【387】Python format 格式化函数
参考:Python format 格式化函数 # 保留小数点后两位 f'{3.1415926:.2f}' # 带符号保留小数点后两位 f'{3.1415926:+.2f}' f'{-1:+.2f}' ...
- LeetCode OJ 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2-&g ...
- Ajax 学习 第三篇
1.什么是json 第一种方法 第二种方法 比较evar and jsondata 任何时候使用EVAR要特别小心,他不会管输入对象的类型 JSONLint可以在线校验代码的正确性 改写代码
- 在Centos 6.5 X64下切割m3u8
操作系统:centos 6.5 必需要参考的文章: http://blog.chinaunix.net/uid-23069658-id-4018842.html 准备工作: 安装git yum ins ...
- AndroidScreenSlide项目切换view动画效果《IT蓝豹》
AndroidScreenSlide项目切换view动画效果 AndroidScreenSlide项目中有几个不错的效果,一:Card Flip翻页立体效果,二:Screen Slide 左右切换vi ...
- linux 挂载磁盘
挂在磁盘操作(还有一个300G的盘没显示出来): [root@iZgo67bo9s3uaijzqrgbaxZ ori]# df -h Filesystem Size Used ...