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)点的一个二次曲线 在给你一个tx,px,角A,问你在tx点二次曲线和切线还有x轴正半轴围成的曲线。
**【思路】:**求出二次曲线的表达式然后定积分求面积即可。
设二次曲线的表达式为 y=axx+b*x+c;
因为其过(0,0)点所以 c=0;
方程两边求导 y’=2ax+b
在(0,0)点的倒数为 b 用因为角AOX=角A 所以 b=tan(角A);
接下来仅需要求a即可:利用RT三角形TPD(设从TX点做垂直与x轴正半轴的直线与二次曲线的交点为D)
绝对值 tan(角DPT)=AT/PT;(注意这里的斜率是负的所以加绝对值)
推出来 -2at-b=(att+bt)/(p-t);
令c=p-t; 偷懒方便书写
a=(-bc-bt)/(tt+2tc);
最后直接求面积即可 总面积=定积分求二次曲线面积+三角形DPT面积
S=(a/3)ttt+(b/t)tt+0.5(att+b*t)*c。
【代码】:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;
const int N=5e5+10;
//设给你的二次函数的解析式为y=a*x*x+b*x+c
//然后输入的 p为px t为Tx jiao为角AOX的大小
int main()
{
int T;
cin>>T;
while(T--)
{
double ans=0,a=0,b=0,jiao=0,p,t,c;
cin>>p>>t>>jiao;
c=p-t;
b=tan(jiao);
a=1.0*(-b*c-b*t)/(t*t+2*t*c);
ans=(1.0/3.0)*t*t*t*a+0.5*b*t*t+0.5*(a*t*t+b*t)*c;
printf("%.3lf\n",ans);
}
return 0;
}