The area

2024-08-24 22:38
文章标签 area

本文主要是介绍The area,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

万恶的高数微分不会啊!!眼馋队友用微分刷刷的做出来的同时,只能用悲催的二分法终于二出来了。。。

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 picture, can you tell Ignatius the area of the land? 

Note: The point P1 in the picture is the vertex of the parabola. 


Input

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). 

Output

For each test case, you should output the area of the land, the result should be rounded to 2 decimal places. 

Sample Input

    
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

Sample Output

    
33.33 40.69
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <math.h>
const double e=1e-3;
double a,h,d;
double fx(double x)
{return a*(x-h)*(x-h)+d;
}
double area(double x1,double y1,double x2,double y2,double x3,double y3)
{double d1,d2,d3,p,s,x4,y4;d1=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));if (d1<e) return 0;d2=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));d3=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));p=(d1+d2+d3)/2;s=sqrt(p*(p-d1)*(p-d2)*(p-d3));x4=(x1+x2)/2; y4=fx(x4);s+=area(x4,y4,x1,y1,x2,y2);x4=(x1+x3)/2; y4=fx(x4);s+=area(x4,y4,x1,y1,x3,y3);return s;
}
int main()
{double x1,y1,x2,y2,x3,y3,s;int n,i;scanf("%d",&n);for (i=0;i<n;i++){scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);h=x1; d=y1;a=(y2-d)/(x2-h)/(x2-h);s=area(x1,y1,x2,y2,x3,y3);printf("%.2lf\n",s);}
}


这篇关于The area的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1103806

相关文章

[LeetCode] 695. Max Area of Island

题:https://leetcode.com/problems/max-area-of-island/description/ 题目 Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizont

监控flash_recovery_area的使用情况(V$FLASH_RECOVERY_AREA_USAGE,V$RECOVERY_FILE_DEST)

--监控flash_recovery_area的使用情况(V$FLASH_RECOVERY_AREA_USAGE,V$RECOVERY_FILE_DEST)SYS@PROD1> select * from V$FLASH_RECOVERY_AREA_USAGE;FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF

Area of Polycubes(简单模拟)

http://poj.org/problem?id=3792 题意:给出n个立方体的三维坐标,在每个立方体与之前的立方体有公共边的前提下输出他们的表面积,否则输出NO,并输出不合法的立方体编号。 注意有重的立方体,也输出NO。 #include <stdio.h>#include <string.h>#include <algorithm>#include <cmath

innovus:report_area和reportGateCount报告module面积的差异

我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧? 拾陆楼知识星球入口 相关文章链接:

POJ 2375 Cow Ski Area (强连通分量)

题目地址:POJ 2375 对每个点向与之相邻并h小于该点的点加有向边。然后强连通缩点。问题就转化成了最少加几条边使得图为强连通图,取入度为0和出度为0的点数的较大者即可。注意,当强连通分量只有一个的时候,答案是0,而不是1. 代码如下: #include <iostream>#include <string.h>#include <math.h>#include <queue>

Leetcode 3195. Find the Minimum Area to Cover All Ones I

Leetcode 3195. Find the Minimum Area to Cover All Ones I 1. 解题思路2. 代码实现 题目链接:3195. Find the Minimum Area to Cover All Ones I 1. 解题思路 这一题还是挺简单的,只要找到所有1所在的元素的上下左右4个边界,作为目标矩形的四个边即可。 2. 代码实现 给出python

数据库设计之area区域表

这个用起来还可以的比较全,是2015年更新的 在这个版本的数据上我做了个小的改动,如果你使用不方便可以参考改版后的数据:http://blog.csdn.net/u012012240/article/details/51314647 -- phpMyAdmin SQL Dump-- http://www.phpmyadmin.net---- 主机: localhost-- 生成日期:

使用area标签实现标签的嵌套

在项目中我们会碰到这种需求:即点击这个整个a标签跳转到一个页面,点击a里面的某个a再跳转到另一个页面。有人会说,这还不简单,直接a标签嵌套a标签,可是事实如此吗,看代码: <a href="#">clickOne<a href="#">clickTwo</a></a>   此时的节点结构是a嵌套这a,但是经过页面解析以后: 嵌套关系成了兄弟关系。这是因为a标签不能去嵌套a标签,所

catalog recovery area后回到incarnation任一时刻

1. controlfile 一定要足够早,那就是list incarnation 只有两个的时候 2. catalog recovery area 后默认最新的incarnation,需要结合 SCN号切换incarnation. 3. set until scn  7620291; 一定要比list incarnation 中的值大于1,否则就是早一个的incarnation -----

sdut——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 int