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 ...
随机推荐
- J2SE 8的流库 --- 基本类型流的使用
展现流的方法 public static <T> void show(String title, Stream<T> stream){ System.out.println(& ...
- 浅谈 CAS
CAS: CAS:Compare and Swap, 翻译成比较并交换. java.util.concurrent包中借助CAS实现了区别于 synchronized 同步锁的一种乐观锁. CAS应用 ...
- PHP中Notice: unserialize(): Error at offset of bytes in on line 的解决方法
使用unserialize函数将数据储存到数据库的时候遇到了这个报错,后来发现是将gb2312转换成utf-8格式之后,每个中文的字节数从2个增加到3个之后导致了反序列化的时候判断字符长度出现了问题, ...
- android平台yuv缩放相关<转>
Android的视频相关的开发,大概一直是整个Android生态,以及Android API中,最为分裂以及兼容性问题最为突出的一部分.摄像头,以及视频编码相关的API,Google一直对这方面的控制 ...
- table布局与div布局
DIV与TABLE本身并不存在什么优缺点,所谓web标准只是推荐的是正确的使用标签,好比说:DIV用于布局,而TABLE则本来就是转二维数据的.让TABLE做该做的事,并不是说页面里不出现TABL ...
- linux 时间相关的一些总结
仅作为内核代码中时间管理模块的笔记,3.10内核,很乱,不喜勿喷. 先有time,后有timer. 常用的time结构有哪些?除了大名鼎鼎的jiffies和jiffies64之外,还有常用的一些结构如 ...
- DNS泛解析配置
多个域名走同一个nginx代理服务器,多个域名如果有相同的后缀,就可以使用泛解析了,配置如下 编辑文件:/etc/dnsmasq.conf address=/aa.com/172.16.10.10 a ...
- C# 递归获取 文件夹的 所有文件
public void Director(string dir, List<string> list) { DirectoryInfo d = new DirectoryInfo(dir) ...
- C 中的typedef应用
1. typedef 声明的新的类型名在变量名的位置出现. example: typedef unsigned int UINT 则 unsigned int a; 相当于 UINT A; 2. t ...
- Electrom will-download pause function
1.code from github url-link: https://github.com/electron/electron/issues/7712 // to store downloadIt ...