angry_birds_again_and_again

来源:互联网 发布:查找算法. 编辑:程序博客网 时间:2024/06/03 18:16

题目描述

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 lineO-Tappingposition-Pig-O)

输入

The first line contains only one integerT (T is about1000) indicates the number of test cases. For each case there are two integers,pxtx, and a float numberα.(0 < Tx ≤ Px ≤ 1000,0 < α < π/2) .

输出

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

样例输入

12 1 1.0

样例输出

0.692
 
//题意:求由实线O-Tappingposition-Pig-O所围成图形的面积 s.#include<stdio.h>#include<math.h>int main(){int n;scanf("%d",&n);while(n--){int t,p;double a,t1,t2;scanf("%d%d%lf",&p,&t,&a);t1=p*t*(3*p-2*t);t2=6*(2*p-t);printf("%.3lf\n",t1/t2*tan(a));}return 0;}/*由题意可设抛物线方程为f(x)=a*x^2+b*x ,Tap点的纵坐标为 y,由O-Tappingposition-Tx-O所围成图形的面积为 s1, 由Tx-Tappingposition-pig-Tx所围成图形的面积为s2.f'(x)=2*a*x+bs=s1+s2  ...... (1)s2=1/2*(px-tx)*y  ...... (2)s1=1/3*a*tx^3+1/2*b*tx^2  ...... (3)f'(0)=tan(a) => b=tan(a)  ...... (4)f(tx)=y => a*tx^2+b*tx=y  ...... (5)f'(tx)=-y/(px-tx) => 2*a*tx+b=-y/(px-tx)  ...... (6)联立(1)(2)(3)(4)(5)(6)解得:s=[px*tx*(3*px-2*tx)]/[6*(2*px-tx)]*tan(a)*/


0 0
原创粉丝点击