Football Goal(簡單數學題)

題目來源:[NWPU][2014][SRM][4]  F題

http://vjudge.net/contest/view.action?cid=51335#problem/F



作者:npufz

題目:

F - Football Goal
Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

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 ≤ ab ≤ 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 Input

input output
2 2
4.828427125


代碼:

#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    double   a,b;
    cin>>a>>b;
    printf("%.9lf\n",(a*a+b*b)/4.0+sqrt(2)*a*b/2.0);
    return 0;
}

反思:一開始覺得兩條邊爲一個圓的的弦時最大,就開始求角,由於過於着急就錯了,後來冷靜下來就推出了公式,就A了,但是沒有給出證明,相信自己,沉着求解很關鍵







反思:

發佈了42 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章