2014年山东ACM第五届省赛 angry_birds_again_and_again(数学积分)
2016-04-27 17:39
453 查看
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
设方程 y=ax^2+bx+c ,图中曲线经过原点,所以c=0.
对方程求导 y'=2ax+b , 此时 y'代表斜率,将原点(0,0)带入得:y'=b即该点的斜率,所以b=tan( A)
然后根据两条切线的斜率求出a的值a=(-b*tx-b*(px-tx))/(2*tx*(px-tx)+tx*tx)。
这样对y进行0到tx积分求出弧面的面积,再加上三角形的面积。
s=((a*tx*tx*tx)*(1/3.0)+(b*tx*tx)*0.5)+((a*tx*tx+b*tx)*(px-tx)*0.5)。注:double型要除以3.0而不能是3。
#include<stdio.h> #include<math.h> int main() { int n; scanf("%d",&n); while(n--) { double px,tx,A; double s; scanf("%lf %lf %lf",&px,&tx,&A); double b=tan(A); double a=(-b*tx-b*(px-tx))/(2*tx*(px-tx)+tx*tx); s=((a*tx*tx*tx)*(1/3.0)+(b*tx*tx)*0.5)+((a*tx*tx+b*tx)*(px-tx)*0.5); printf("%.3lf\n",s); } }
相关文章推荐
- error: linker command failed with exit code 1 (use -v to see invocation)怎么解决
- Climbing Stairs 带测试版
- win7系统开机提示cpu variable mtrr configure failed解决方法
- relation "public.***" contains more than "max_fsm_pages" pages with useful free space
- fail2ban 配置文件说明
- SSH登陆 Write failed: Broken pipe解决办法
- Vagrant: Warning: Authentication failure. Retrying
- Codeforces 582B Once Again... 【LIS变形】
- 【翻译】Xibo官方文档6-CMS Maintenance
- 朴素贝叶斯 垃圾邮件检测 Naive Bayes Spam detection
- CSAcademy Beta Round #4 Swap Pairing
- 山东省第五届ACM省赛题——Painting Cottages(求点集的划分)
- CGRectContainsPoint的具体用法解释
- 理解 %IOWAIT (%WIO)
- TIME_WAIT和CLOSE_WAIT状态区别
- You have new mail in /var/spool/mail/root
- leetcode 11. Container With Most Water
- fn contains 包含字符串 三种方法判断
- Troubleshooting 'library cache: mutex X' waits. (文档 ID 1357946.1)
- 习近平主席关心人工智能事业的发展