天天看点

ZOJ 2748 Free Kick

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

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<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
#define rep(i,j,k) for (int i=j;i<=k;i++)
#define per(i,j,k) for (int i=j;i>=k;i--)
#define inone(x) scanf("%d",&x)
#define intwo(x,y) scanf("%d%d",&x,&y)
typedef pair<int,int> pii;
const int N = 2005;
const int M = 00001;
const int INF=0x7FFFFFFF;
int T,n;
double a,W,x,y,D,A;

int main()
{
    while (~scanf("%lf%lf%lf%lf%lf%lf",&a,&W,&x,&y,&D,&A))
    {
        double AA=sqrt((x-a)*(x-a)+y*y);
        double BB=sqrt((x+a)*(x+a)+y*y);
        double CC=a+a;
        double cc=acos((AA*AA+BB*BB-CC*CC)/2/AA/BB);
        cc-=A/180*acos(-1.0);
        if (cc<=0) printf("0\n");
        else
        {
            D=D*tan(cc/2)*2;
            D/=W;
            printf("%.0lf\n",ceil(D));
        }
    }
    return 0;
}