TOJ 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] 即为答案

代码

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3
 4 int main()
 5 {
 6     int T;
 7     scanf("%d",&T);
 8     while(T--)
 9     {
10         double x1,y1,x2,y2,x3,y3,a1,b1,a,b,c,ans;
11         scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
12         a1=(y3-y2)/(x3-x2);
13         b1=y3-a1*x3;
14         a=((y3-y1)-a1*(x3-x1))/((x3*x3-x1*x1)-(x3+x2)*(x3-x1));
15         b=((y3-y2)-a*(x3*x3-x2*x2))/(x3-x2);
16         c=y3-a*x3*x3-b*x3;
17         ans=((1.0/3)*a*x3*x3*x3+0.5*(b-a1)*x3*x3+(c-b1)*x3)-((1.0/3)*a*x2*x2*x2+0.5*(b-a1)*x2*x2+(c-b1)*x2);
18         printf("%.2f\n",ans);
19     }
20     return 0;
21 }

原文地址:https://www.cnblogs.com/taozi1115402474/p/9465359.html

时间: 2024-10-29 15:20:15

TOJ 1210 The area(微积分)的相关文章

【TOJ 1449】Area of Circles II

描述 There are two circles on the plane. Now you must to calculate the area which they cover the plane. For example, in Figure 1, the area of the red region is the answer of this problem. 输入 The input contains multiple test cases. The first line contai

HDU 1071 The area ——微积分

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

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

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

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

杭电ACM 三 在坐标系中的微积分

问题及代码 Problem Description 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 p

数据库设计之area区域表改版后

原先版本:http://blog.csdn.net/u012012240/article/details/51221080 原先版本直辖市的省级别和市级别为1条记录,1条记录即代表省又代表市,操作起来很不方便! 这个版本创建了个直辖市记录为省级记录,将原先直辖市记录的parent改为省级直辖市的id,这样方便操作及理解! /* SQLyog v10.2 MySQL - 5.6.17 : Database - whiteshirt *********************************

HDU 1071 微积分

The area Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7611    Accepted Submission(s): 5332 Problem Description Ignatius bought a land last week, but he didn't know the area of the land becaus

POJ 2546 &amp; ZOJ 1597 Circular Area 两圆的面积交

Circular Area Time Limit: 2 Seconds      Memory Limit: 65536 KB Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point. Input In the single line of in