angry_birds_again_and_again SD5THACM


angry_birds_again_and_again

Time Limit: 2000MS Memory limit: 65536K

題目描述

The problems called "Angry Birds" and "Angry Birds Again and Again" has been solved by many teams in the series of contest in 2011 Multi-University Training Contest.
 
This time we focus on the yellow bird called Chuck. Chuck can pick up speed and distance when tapped.
 
You can assume that before tapped, Chuck flies along the parabola. When tapped, it changes to fly along the tangent line. The Chuck starts at the coordinates (0, 0). Now you are given the coordinates of the pig (Px, 0), the x-coordinate of the tapping position (Tx) and the initial flying angle of Chuck (α).

∠AOx = α
Please calculate the area surrounded by Chuck’s path and the ground.(The area surrounded by the solid line O-Tapping position-Pig-O)

輸入

The first line contains only one integer T (T is about 1000) indicates the number of test cases. For each case there are two integers, px tx, and a float number α.(0 < Tx ≤ Px ≤ 1000, 0 < α <  ) .

輸出

One line for each case specifying the distance rounded to three digits.

示例輸入

1
2 1 1.0

示例輸出

0.692

數學題:已知一個二次函數過零點的角度,已知另外一條切線,求x軸與直線和二次函數包圍的取餘面積
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int T,n,px,tx;
double s1,s2,b,c;
float a;


int main()
{
    cin >> T;
    while(T--)
    {
        cin >> px >> tx >> a;
        c = tan(a);
        b = c * px / (tx * tx - 2 * px * tx);
        //cout << b << endl;
        s1 = b / 3.0 * (tx * tx * tx) + c / 2.0 * tx * tx;
        //cout << s1 << endl;
        s2 = 1 / 2.0 * (b * tx * tx + c * tx) * (px - tx);
        //cout << s2 << endl;
        printf("%.3lf\n",s1 +s2);
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章