山东省第五届ACM省赛题——angry_birds_again_and_again(计算几何)
2016-04-20 10:48
573 查看
题目描述
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
抛物线f(x)=ax^2+bx+c,斜率为导数f’(x)=2ax+b。因为经过原点,所以c=0,又知道原点的斜率为tan(α)=b。
a的话,知道了tx和px组成的三角形,在tx处的斜率为f(tx)/(px-tx),注意此时斜率为负数。
知道了a,b,c就可以求定积分来计算抛物线的面积了
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
抛物线f(x)=ax^2+bx+c,斜率为导数f’(x)=2ax+b。因为经过原点,所以c=0,又知道原点的斜率为tan(α)=b。
a的话,知道了tx和px组成的三角形,在tx处的斜率为f(tx)/(px-tx),注意此时斜率为负数。
知道了a,b,c就可以求定积分来计算抛物线的面积了
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set> #include <queue> #include <stack> #include <map> #include <bitset> using namespace std; int main() { double px,tx,alpha,ans,b,a; int T; scanf("%d",&T); while(T--) { scanf("%lf%lf%lf",&px,&tx,&alpha); b=tan(alpha); //cout<<b<<endl; a=(b*px)/(tx*tx-2*px*tx); //cout<<a<<endl; ans=1.0/3.0*a*pow(tx,3)+0.5*b*tx*tx; ans+=0.5*(px-tx)*(a*tx*tx+b*tx); printf("%.3lf\n",ans); } return 0; }
相关文章推荐
- [CareerCup] 17.3 Factorial Trailing Zeros 求阶乘末尾零的个数
- IDXGISwapChain接口
- 人工智能60年:机器审美观
- su: cannot set user id: Resource temporarily unavailable
- su: cannot set user id: Resource temporarily unavailable
- su: cannot set user id: Resource temporarily unavailable
- 山东省第五届ACM大学生程序设计竞赛 angry_birds_again_and_again 求积分
- JetBrains 加入 .NET 基金会
- 人工智能、大数据、金融和SaaS四大风口上看风向
- No grammar constraints (DTD or XML schema).....两种解决方法
- Altium designer 原理图转换为pcb时出现的 unknown pin 和 failed to add class member
- Naive Bayes算法(朴素贝叶斯算法)
- 归并排序
- DDD 领域驱动设计-如何完善 Domain Model(领域模型)?
- Could not find class 'org.jivesoftware.smackx.PrivateDataManager$PrivateDataIQProvider', r
- HDU 4251 The Famous ICPC Team Again (划分树)
- error: linker command failed with exit code 1 (use -v to see invocation) 报错的原因
- ZOJ 3870 本篇文章转载自——白羊_baiyang
- Chilkat----开源站点之VS2010 CKMailMan一个很好的邮件发送开源开发包
- 03-树3 Tree Traversals Again (25分)