山东省第五届ACM省赛题——angry_birds_again_and_again(计算几何)
来源:互联网 发布:C语言exit(-1) 编辑:程序博客网 时间:2024/05/29 23:23
题目描述
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;}
- 山东省第五届ACM省赛题——angry_birds_again_and_again(计算几何)
- 2014山东省第五届ACM省赛 angry_birds_again_and_again
- 2014年山东省第五届ACM--angry_birds_again_and_again
- 第五届山东省ACM angry_birds_again_and_again(积分)
- 2014山东省第五届ACM省赛 angry_birds_again_and_again
- 山东省第五届ACM大学生程序设计竞赛-angry_birds_again_and_again(积分)
- 山东省第五届ACM大学生程序设计竞赛 angry_birds_again_and_again 求积分
- 山东省第四届ACM省赛题——Rescue The Princess(计算几何)
- 第四届 山东省ACM Rescue The Princess(计算几何)
- 第五届ACM大学生程序设计竞赛:angry_birds_again_and_again
- 山东省第五届ACM省赛题——Full Binary Tree(二叉树应用)
- 山东省第五届ACM省赛题——Hearthstone II(第二类Stiring数)
- 山东省第五届ACM省赛题——Weighted Median(模拟)
- 山东省第五届ACM省赛题——Colorful Cupcakes(四维dp)
- 山东省第五届ACM省赛题——Circle(递推求概率)
- 山东省第五届ACM省赛题——Painting Cottages(求点集的划分)
- 山东省第五届ACM省赛题——Devour Magic(线段树区间覆盖+更新)
- 第五届山东省ACM Circle(高斯消元)
- java的final关键字——修饰变量
- diff and patch
- 色彩
- line-height
- ps一些用法记录
- 山东省第五届ACM省赛题——angry_birds_again_and_again(计算几何)
- Reactor与Proactor的概念
- css <font>标签让一行字有大有小的显示
- 仿今日头条下拉出现SearchBar,再下拉刷新效果,SearchListView实现以及原理讲解
- Problem1013
- 二叉树上最长单色路径
- EditText限制、String切割
- java字符串翻转
- 每日随笔小记-4月20日