[ACM] sdut 2877 angry_birds_again_and_again (简单数学积分)
来源:互联网 发布:烟风煤粉管道设计软件 编辑:程序博客网 时间:2024/06/03 14:48
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.
示例输入
12 1 1.0
示例输出
0.692
提示
来源
2014年山东省第五届ACM大学生程序设计竞赛
解题思路:
设方程 y=ax^2+bx+c ,图中曲线经过原点,所以c=0.
对方程求导 y'=2ax+b , y'代表斜率,那么原点(0,0)这一点,代人y'=b,即该点的斜率,根据题意b=tan( α)
如图:在题目中x=tx这一点时,容易混,记tx为t, 图中曲线x=t这一点,该点的斜率为 2at+b . 注意斜率是负的
三角形竖着的直角边除以横着的直角边(p-t)的值的相反数即为斜率 2at+b
竖着的直角边值为 at^2+bt (将t带入原方程),横着的直角边为p-t,则有式子
2at+b= - ( at^2+bt)/(p-t)
解出a,这样方程中a,b的值都有了。
那么题目所求的面积即为 曲线覆盖面积 从 0到t积分 积分函数为(ax^2+bx) ,再加上三角形的面积 0.5*(p-t)*(at^2+bt)
代码:
#include <iostream>#include <cmath>#include <iomanip>using namespace std;double px,tx,jiao;double a,b;int main(){ int t;cin>>t; while(t--) { cin>>px>>tx>>jiao; b=tan(jiao); double m=px-tx; a=(-b*tx-b*m)/(2*tx*m+tx*tx); double ans; ans=(1/3.0)*a*tx*tx*tx+0.5*b*tx*tx+0.5*(px-tx)*(a*tx*tx+b*tx); cout<<setiosflags(ios::fixed)<<setprecision(3)<<ans<<endl; } return 0;}
0 0
- [ACM] sdut 2877 angry_birds_again_and_again (简单数学积分)
- 2014年山东ACM第五届省赛 angry_birds_again_and_again(数学积分)
- SDUT 2877:angry_birds_again_and_again
- 第五届山东省ACM angry_birds_again_and_again(积分)
- 山东省第五届ACM大学生程序设计竞赛-angry_birds_again_and_again(积分)
- 山东省第五届ACM大学生程序设计竞赛 angry_birds_again_and_again 求积分
- 小学数学(Java)acm.sdut
- <sdut-ACM> 3470数学黑洞
- sdut acm 简单字符串排序
- Java sdut acm 2445 小学数学
- Java SDUT ACM 2445 小学数学
- 1204 ACdream Integration of Polynomial(数学:简单求积分)
- angry_birds_again_and_again
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
- SDUT 3896 HEX 山东第八届ACM大赛D题(组合数学)
- 山东省第五届ACM省赛题——angry_birds_again_and_again(计算几何)
- 2014山东省第五届ACM省赛 angry_birds_again_and_again
- 2014年山东省第五届ACM--angry_birds_again_and_again
- SDUT 2498 AOE网上的关键路径(SPFA 最长路径)
- poj 1101 The Game bfs
- 利用指针传递二维数组进行行列式转置
- 算法导论2.4 合并排序求逆序数
- dsp EDMA学习与疑问
- [ACM] sdut 2877 angry_birds_again_and_again (简单数学积分)
- java 数据转换
- 20141127-Capture与Capture CIS的区别
- android线程池的理解
- 中序线索化二叉树
- Java 基础总结
- iOS网络基础--发送同步、异步请求
- nyoj1110 一个简单数学题
- 解决信道系数为什么是复数问题