2014山东省第五届ACM省赛 angry_birds_again_and_again

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 (α).
2014山东省第五届ACM省赛 angry_birds_again_and_again_第1张图片
∠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

提示

 

来源

2014年山东省第五届ACM大学生程序设计竞赛


题意:小鸟从(0,0)开始以α角飞出,轨迹是抛物线,到横坐标为Tx处开始沿切线方向飞,撞到(P,0)处的猪。求它飞行轨迹与x轴围的面积。

设抛物线方程 y = -Ax^2+Bx . 求导,根据两个斜率求出A和B,然后积分就好,最后再加上三角形的面积。

#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int T;
    double A,t,p;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lf%lf%lf",&p,&t,&A);
        double b=tan(A);
        double a=b*p/(2*t*t-2*p*t-t*t);
        double area=(1/3.0)*a*t*t*t+0.5*b*t*t+(p-t)*(a*t*t+b*t)*0.5;
        printf("%.3lf\n",area);

    }
    return 0;
}

你可能感兴趣的:(2014山东省第五届ACM省赛 angry_birds_again_and_again)