HDOJ 1071 The area

2024-05-05 12:48
文章标签 area 1071 hdoj

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

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1071

题目:

The area

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7341    Accepted Submission(s): 5138


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

解题思路:

求抛物线y = ax^2 + bx + c与一条直线y=f(x)围成的区域的面积S。S = SA - SB,SA表示抛物线与直线x = x2, x = x3 , y = 0围成的区域的面积,SB表示直线x = x2, x = x3 , y = 0 与 y = f(x)围成的梯形的面积。SB = 1/2 * (y2+y3) * (x3 - x2), SA = ∫ (ax^2 + bx + c) dx (x2->x3)从x2到x3积分。我们计算一下可以得到,S = 1/6 * a * (x2 - x3)^3, 剩下来的就是要求出a了。由抛物线的性质x1 = -b / (2a), 所以b = -2ax1。建立方程组 y1 = ax1^2 - 2ax1^2 + c, y3 = ax3^2 - a2x1*x3 + c;两式相减并化简得a = (y3 - y1) / (x1 - x3)^2.最后,我们就可以得到公式S = 1/6 *(y3 - y1) * (x2 - x3) / (x1 - x3) ^ 3。ps:纯数学题,高数忘得差不多了,算公式算了好久啊。


代码:

#include <cstdio>int main()
{int t;while(~scanf("%d", &t)){while(t--){double x1, y1, x2, y2, x3, y3;scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);printf("%.2f\n", (y3-y1)*(x2-x3)*(x2-x3)*(x2-x3)/6.0/(x1-x3)/(x1-x3));}}return 0;
}


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



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

相关文章

[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

hdoj 2371 decoded string. Decode the Strings

http://acm.hdu.edu.cn/showproblem.php?pid=2371 题意:给出编码的原则,给一个字符串,输出该字符串经过m次解码后的字符串。 啊啊啊啊。。。。无耻的看错题意了,以为给出字符串输出经过m次解码的后的字符串,样例死活过不了,赛后才发现问的是“decoded string”. 即解码后的字符串。。 思路:对于 5 3 2 3 1 5 4 helol

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

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

HDOJ 1874 畅通工程续——结构体模拟邻接链表的SPFA算法

Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。   Input 本题目包含多组数据,请处理到文

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 li

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

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

九度OJ-1435-迷瘴(HDOJ-2570)

题目地址:点击打开链接 题目描述: 通过悬崖的yifenfei,又面临着幽谷的考验—— 幽谷周围瘴气弥漫,静的可怕,隐约可见地上堆满了骷髅。由于此处长年不见天日,导致空气中布满了毒素,一旦吸入体内,便会全身溃烂而死。 幸好yifenfei早有防备,提前备好了解药材料(各种浓度的万能药水)。现在只需按照配置成不同比例的浓度。 现已知yifenfei随身携带有n种浓度的万能药水,体积V都相

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