URAL 1874. Football Goal(数学 浮点数三分)
来源:互联网 发布:经济学书籍推荐 知乎 编辑:程序博客网 时间:2024/06/05 16:21
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1874
Unlike most students of the Mathematical Department, Sonya is fond of not only programming but also sports. One fine day she went to play football with her friends. Unfortunately, there was no football field anywhere around. There only was a lonely birch tree in a corner of the yard. Sonya searched the closet at her home, found two sticks, and decided to construct a football goal using the sticks and the tree. Of course, the birch would be one of the side posts of the goal. It only remained to make the other post and the crossbar.
Sonya wanted to score as many goals as possible, so she decided to construct a goal of maximum area. She knew that the standard football goal was rectangular, but, being creative, she assumed that her goal could have the form of an arbitrary quadrangle.
You can assume that the birch tree is a segment of a straight line orthogonal to the ground.
Input
The only line contains integers a and b, which are the lengths of the sticks (1 ≤ a, b ≤ 10 000). It is known that the total length of the sticks is less than the height of the birch tree.
Output
Output the maximum area of the goal that can be constructed with the use of the sticks and the birch tree. The answer must be accurate to at least six fractional digits.
Sample
2 2
4.828427125
Problem Author: Fedor Fominykh
Problem Source: Ural Regional School Programming Contest 2011
Problem Source: Ural Regional School Programming Contest 2011
题意:
形成球门,现在有两根棍子,和一棵树形成的柱子(与地面垂直)!
求能形成的最大面积?(地面也算一边)
PS:
四边形的面积ACBD由三角形ACB和三角形ABD组成。
设AB的长度为z,
那么三角形ACB的最大面积是 z*z/4.
三角形ABD的面积用海伦公式可以表示出来。
z是变长,范围是[0,x+y].
面积公式是凸性函数,对z进行三分就行了。
代码如下:#include <cstdio>#include <cstring>#include <cmath>#include <iostream>#include <algorithm>using namespace std;#define eps 1e-8double cal(double a, double b, double c){ double p = (a+b+c)/2; return sqrt(p*(p-a)*(p-b)*(p-c))+c*c/4.0;}int main(){ double a, b; while(~scanf("%lf %lf",&a,&b)) { if(a > b) { swap(a, b); } double l = 0; double r = a+b; while(l + eps < r) { double mid = (l+r)/2.0; double s1 = cal(a, b, mid); double midmid = (mid+r)/2.0; double s2 = cal(a, b, midmid); if(s1 > s2) r = midmid; else l = mid; } printf("%.8lf\n",cal(a, b, l)); } return 0;}
1 0
- URAL 1874. Football Goal(数学 浮点数三分)
- URAL 1874 Football Goal 均值不等式&三分
- ural 1874 Football Goal
- Ural 1874 Football Goal
- timus 1874. Football Goal URAL 解题报告 计算几何
- 三分--Football Goal(面积最大)
- 1874. Football Goal
- hdu1701(数学 浮点数)
- Football Goal(简单数学题)
- URAL 1534 Football in Gondor
- 浮点三分模板
- URAL 1753 Bookshelf (三分答案)
- HDU 4355 数轴上的点找使Si^3*Wi最小的和-浮点数三分
- 数学-三分->讲解
- ZOJ -3203 三分+数学
- 说说C#的数学类,Math,浮点数(上)
- C#中的数学类,Math,浮点数(中)
- shell中的数学计算:正式和浮点数的计算
- 初识Xamarin——mac os x下环境的搭建
- linux的pam验证
- 最短路-弗洛伊德(Floyd)算法
- HDOJ 2064 汉诺塔III
- tarjan算法
- URAL 1874. Football Goal(数学 浮点数三分)
- ssh实现ajax最简单的方法
- 1013
- EhCache 分布式缓存/缓存集群
- Dedecms实现统计真实下载次数的方法
- [Java学习笔记]Java简介
- Bilibili 2000W用户信息爬取
- 提交表单时数据检测
- 使用Dragonboard 410c开发医疗物联网