-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDolphin.java
More file actions
64 lines (52 loc) · 1.4 KB
/
Dolphin.java
File metadata and controls
64 lines (52 loc) · 1.4 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Scanner;
public class Dolphin {
public static void main(String[] args){
int testCase = 0;
int input = 0;
int currentRound = 0;
int oldRound = 0;
int dolphin = 1;
int jump = 1;
Scanner number = new Scanner(System.in);
System.out.print("Input testcase : ");
testCase = number.nextInt();
if((testCase >= 1) && (testCase <= 1000)){
for(int i = 1; i <= testCase; i++){
System.out.print("Input : ");
input = number.nextInt();
if(input == 0){
i = testCase + 1;
continue;
}
oldRound = 0;
currentRound = 0;
dolphin = 1;
jump = 1;
for(int j = 1 ; j <= 2000000000 ; j++){
oldRound = currentRound;
currentRound += j*3;
if((input <= currentRound) && (input <= 2000000000)){
if((input - oldRound) <= dolphin * j){
if(oldRound != 0){
System.out.println(j + " dolphins");break;
}else{
System.out.println(j + " dolphin");break;
}
}else if((input - oldRound) <= (dolphin + jump) * j){
if(oldRound != 0){
System.out.println(j + " jumps");break;
}else{
System.out.println(j + " jump");break;
}
}else {
System.out.println("splash");break;
}
}
}
}
System.out.println("END");
} else {
System.out.println("Error");
}
}
}