Skip to content

Commit

Permalink
Feat: Add solution of #118
Browse files Browse the repository at this point in the history
  • Loading branch information
Dltmd202 committed Jul 22, 2022
1 parent 7b65241 commit 8ed0a26
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/BaekJoon/Dltmd202/2869/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
* 달팽이는 올라가고 싶다
* https://www.acmicpc.net/problem/2869
*/
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();

public static void main(String[] args) throws IOException {
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int v = Integer.parseInt(st.nextToken());

System.out.println(getDayAfter(a, b, v));
}

private static int getDayAfter(int a, int b, int v) {
int leftDistanceExceptLastDay = v - a;
int leftDayNeed = (int) Math.ceil((double) leftDistanceExceptLastDay / (a - b));
return leftDayNeed + 1;
}
}
43 changes: 43 additions & 0 deletions src/BaekJoon/Dltmd202/4153/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Optional;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder sb = new StringBuilder();

public static void main(String[] args) throws IOException {
while (true){
Optional<int[]> input = getInput();
if (input.isEmpty()) break;
int[] data = input.get();
if(isRightAngle(data)){
sb.append("right\n");
} else {
sb.append("wrong\n");
}
}
System.out.println(sb.toString());
}

private static boolean isRightAngle(int[] data) throws IOException {
return data[2] * data[2] == data[0] * data[0] + data[1] * data[1];
}

public static Optional<int[]> getInput() throws IOException {
StringTokenizer st = new StringTokenizer(br.readLine());
int[] data = new int[3];
for (int i = 0; i < 3; i++) {
data[i] = Integer.parseInt(st.nextToken());
}
if(data[0] == 0 && data[1] == 0 && data[2] == 0)
return Optional.empty();
else {
Arrays.sort(data);
return Optional.of(data);
}
}
}

0 comments on commit 8ed0a26

Please sign in to comment.