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 ...
随机推荐
- day17-函数装饰器
一.什么是装饰器 装饰器可以让其他函数在不需要做任何代码改变的前提下,增加额外的功能,装饰器的返回值也是一个函数对象.在 Python 中,函数是第一类对象,也就是说,函数可以做为参数传递给另外一个函 ...
- python中Strip()函数的用法
Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列. 注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符. str.strip([chars]) ...
- Jupyter-1-安装Anaconda3及更改路径
Jupyter Notebook测试Python3,可以将图文.代码有效融合,进行交互式编程,适合学习讲解及方案沟通. 1.下载Anaconda3 可以到官网或是清华大学软件镜像站去下载. 路径:ht ...
- Xcode 8 注释快捷键失效
sudo /usr/libexec/xpccachectl 重启
- 关于cordova 状态栏设置
https://blog.csdn.net/u011127019/article/details/58104056
- 更新package.json中的dependencies依赖到最新版本 -
我们从别人那里下载一个项目 ,通过package.json里面的依赖 npm install 来安装所需要的各个包 但是 有可能项目很老,我们一个个更新又很麻烦所以 https://blog.csd ...
- FMS Dev Guide学习笔记(权限控制)
一.开发交互式的媒体应用程序 1.关于访问(权限)控制 当一个用户访问服务器的时候,默认情况下,他可以访问所有的流媒体文件和共享对象.但是你可以使用服务端ActionScript为流媒体文件和 ...
- C# HttpWebRequest 模拟下载
C# web 获取服务端cookie 原文地址:https://www.cnblogs.com/louby/p/5569536.html C#多线程环境下调用 HttpWebRequest 并发连接限 ...
- 设置HTML编码为UTF-8
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 删除kafka topic
1.因为项目原因,kakfa通道中经常造成数据阻塞,导致kafka通道中数据量过大,因此我需要将kakfa通道中数据清除(个人项目原因,一直使用一个消费者,只要保证当前消费者不在消费之前很久的数据就可 ...