-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheAmazingHumanCannonball.java
35 lines (29 loc) · 1.1 KB
/
TheAmazingHumanCannonball.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package theamazinghumancannonball;
import java.util.Scanner;
public class TheAmazingHumanCannonball {
public static void main(String[] args) {
Scanner inputScanner = new Scanner(System.in);
int cases = Integer.parseInt(inputScanner.nextLine());
String[] inputArr;
double v;
double angel;
double x;
double hlower;
double hupper;
for(int i = 0; i < cases; i++) {
inputArr = inputScanner.nextLine().split(" ");
v = Double.parseDouble(inputArr[0]);
angel = Math.toRadians(Double.parseDouble(inputArr[1]));
x = Double.parseDouble(inputArr[2]);
hlower = Double.parseDouble(inputArr[3]);
hupper = Double.parseDouble(inputArr[4]);
double t = x/(v*Math.cos(angel));
double y = v*t*Math.sin(angel)-(0.5*9.81*Math.pow(t, 2));
if(hlower > y -1 || hupper < y+1) {
System.out.println("Not Safe");
} else {
System.out.println("Safe");
}
}
}
}