-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDolphins.java
More file actions
44 lines (35 loc) · 933 Bytes
/
Dolphins.java
File metadata and controls
44 lines (35 loc) · 933 Bytes
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
36
37
38
39
40
41
42
43
44
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner number = new Scanner(System.in);
System.out.print("Input testcase : ");
int testcase = number.nextInt();
if(testcase >= 1 && testcase <= 1000){
int input = number.nextInt();
int round = 0;
int old = 0;
for(int j = 1 ; j <= 2000000000 ; j++){
int dolphin = 1, jump = 1;
old = round;
round += j*3;
if(input <= round && input <= 2000000000){
if((input - old ) <= dolphin*j){
if(old != 0){
System.out.print(j + " dolphins");break;
}else{
System.out.print(j + " dolphin");break;
}
}else if((input - old) <= (dolphin + jump) * j){
if(old != 0){
System.out.print(j + " jump");break;
}else{
System.out.print(j + " jump");break;
}
}else {
System.out.print("splash");break;
}
}
}
}
}
}