ZOJ 2748 Free Kick
2015-08-06 17:16
369 查看
In a soccer game, a direct free kick is also awarded to the opposing team if a player commits any of the offences.
A direct free kick in an immediate distance is a nightmare of the goalie. In order to help their goalkeeper, the defenders often choose to stand side by side between the free kick position and the goal, just like a straight "WALL". The goalkeeper expects
the "WALL" can receive the shooting angle as much as possible. However, there are only 11 players in a team and some of them must pay attention to other offenders, so the defenders to make up the "WALL" are quite limited.
Let's make the problem easier on a simplified field map, shown as above. The two ends of the goal locate at (-a,0) and (a,0) respectively, and the free kick position is (x, y). Assuming the body width of every defender is always W,
your task is to determine how many defenders are required at the least to make up the "WALL", so that they can help their goalie receive the shooting angle. According to FIFA's law, all the defender must keep a distance not less than D from the free
kick position. The goalie will feel safe if the remaining shooting angle after the "WALL" is strictly less than A degree.
Input
The input consists of several test cases. In each case, there are six numbers in a single line, indicating a, W, x, y, D and A respectively.
Constraints:
a, W, D, A are all positive numbers;
The distance between the goal and the free kick position is guaranteed greater than D;
The absolute value of each non-zero number is in the range [10-6, 106].
Proceed until the end of file.
Output
For each case, print an integral number on a single line, which denotes the minimal number of defenders is required to make the goalie safe. Note that this number may be greater than 11.
Sample Input
Sample Output
组成等腰时要的最少
A direct free kick in an immediate distance is a nightmare of the goalie. In order to help their goalkeeper, the defenders often choose to stand side by side between the free kick position and the goal, just like a straight "WALL". The goalkeeper expects
the "WALL" can receive the shooting angle as much as possible. However, there are only 11 players in a team and some of them must pay attention to other offenders, so the defenders to make up the "WALL" are quite limited.
Let's make the problem easier on a simplified field map, shown as above. The two ends of the goal locate at (-a,0) and (a,0) respectively, and the free kick position is (x, y). Assuming the body width of every defender is always W,
your task is to determine how many defenders are required at the least to make up the "WALL", so that they can help their goalie receive the shooting angle. According to FIFA's law, all the defender must keep a distance not less than D from the free
kick position. The goalie will feel safe if the remaining shooting angle after the "WALL" is strictly less than A degree.
Input
The input consists of several test cases. In each case, there are six numbers in a single line, indicating a, W, x, y, D and A respectively.
Constraints:
a, W, D, A are all positive numbers;
The distance between the goal and the free kick position is guaranteed greater than D;
The absolute value of each non-zero number is in the range [10-6, 106].
Proceed until the end of file.
Output
For each case, print an integral number on a single line, which denotes the minimal number of defenders is required to make the goalie safe. Note that this number may be greater than 11.
Sample Input
3.66 0.5 5 20.2 9.15 10 3.66 0.5 -5 -20.3 9.15 10
Sample Output
4 3
组成等腰时要的最少
#include<iostream> #include<cmath> using namespace std; int main() { double a,w,x,y,d,A,pi,t; double b,c; double need; int n; pi=3.141592653; while(cin>>a>>w>>x>>y>>d>>A) { b=acos( (((x-a)*(x-a)+y*y)+((x+a)*(x+a)+y*y) - 4*a*a ) / ( 2*sqrt((x+a)*(x+a)+y*y)*sqrt((x-a)*(x-a)+y*y)) ); /// b=acos( (x*x-a*a+y*y) / ( sqrt((x+a)*(x+a)+y*y)*sqrt((x-a)*(x-a)+y*y) ) ); need=b-A*pi/180; //到少要组成的角 t=2 *d*tan(need/2)/w; if(t<=0) { cout<<0<<endl; continue; } if(t-int(t)!=0) n=int(t)+1; else n=int(t); cout<<n<<endl; } return 0; }
相关文章推荐
- TCP为何采用三次握手来建立连接,若采用二次握手可以吗?
- Tomcat性能优化(三) Executor配置
- web 发布
- CentOS 6.4下Percona Xtrabackup安装部署错误处理
- 杭电acm 2143 box
- 【华为oj】m个苹果方n个盘子,多少种方法?
- StrutsPrepareAndExecuteFilter的作用
- 桶排序算法详解
- hibernate连接mysql自动重连
- Windows server2008 搭建ASP接口访问连接oracle数据库全过程记录
- 内存泄露和内存溢出
- 2015080601 - 被拐
- Noise, being a pseudorandom artist
- 解决 unity 用 vs通过wifi 真机联调 一直连接不上
- Ajax异步刷新省市级联
- 突然想起android与mfc差异
- Android中<uses-sdk>属性和target属性分析
- .NET实现定时发送邮件代码(两种方式)
- (2.3.8)HashMap存储结构浅析
- Hibernate POJO为什么要实现Serializable接口