Description
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)
Input
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 < α < ) .
Output
One line for each case specifying the distance rounded to three digits.
Sample Input
1
2 1 1.0
Sample Output
0.692
题型:
数学
题意:
给你一个经过(0,0)点开口向下的一个二次曲线 ,再给出x轴上的点tx,px,角∠AOx,问你在tx点二次曲线,二次曲线的切线和x轴正半轴围成的曲线的面积。
题解:
先求出二次函数表达式,再求不定积分。
求在二次曲线tx处的斜率:
利用RT三角形TPD(设从TX点做垂直与x轴正半轴的直线与二次曲线的交点为D)
绝对值 tan(角DPT)=DT/PT;(注意这里的斜率是负的所以加绝对值) 推出来 -(-2*a*tx+b)=(-a*tx*tx+b*tx)/(px-tx);
即,
a=(b*tx+b*(px-tx))/(tx*tx+2*tx*(px-tx))
(因为要与X轴围城封闭图形,所以tx一定在二次曲线的右半部分,故在tx处的斜率一定为负)
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
double tx,px,rad;
while (T--)
{
scanf("%lf %lf %lf",&px,&tx,&rad);
//设二次函数表达式为y=-a*x*x+b*x
double b=tan(rad);//由导数可知,在(0,0)点的斜率值与b相等
double a=(b*tx+b*(px-tx))/(tx*tx+2*tx*(px-tx));//在tx处的斜率等式求a
double y=-a*tx*tx+b*tx;//在tx的纵坐标
double ans1=-(1.0/3.0)*tx*tx*tx*a+b*0.5*tx*tx;//二次函数0到tx的不定积分
double ans2=y*(px-tx)*0.5;//tx到px的面积
printf("%0.3lf\n",ans1+ans2);
}
return 0;
}