The Amazing Human Cannonball
Time limit1sMemory limit1024 MB
For each test case, the task checks whether the cannonball's height where it crosses the wall is at least 1 m above the lower edge and at least 1 m below the upper edge.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
The amazing human cannonball show is coming to town, and you are asked to double-check their calculations to make sure no one gets injured! The human cannonball is fired from a cannon placed away from a vertical wall. The wall has a hole that the cannonball must fly through. The lower edge of the hole is at height , and the upper edge is at height . The initial velocity is , and the angle of the cannon relative to the ground is .
Thanks to their innovative suits, human cannonballs can fly without air resistance, so their trajectory can be modeled with the following formulas: where give the position of the cannonball at time when it is fired from point . is the acceleration due to gravity ().
Write a program to determine whether the human cannonball can pass safely through the hole in the wall. To pass safely, the point where the trajectory crosses the centerline of the wall must have a vertical safety margin of 1 m above the lower edge and 1 m below the upper edge.
Input
The input has at most 100 test cases. The first line contains an integer , the number of test cases. Each test case has five parameters, , separated by spaces. () is the initial velocity of the ball in m/s. is the angle in degrees (). () is the distance from the cannon to the wall. and () are the heights of the lower and upper edges of the wall. All numbers are floating point numbers.
Output
If the cannonball can pass safely through the wall, print Safe. Otherwise, print "Not Safe"!