From 8ed0a267d0dc0fe94a5bb8f2e227d7b417bd9458 Mon Sep 17 00:00:00 2001 From: Dltmd202 Date: Fri, 22 Jul 2022 11:21:37 +0900 Subject: [PATCH] Feat: Add solution of #118 --- src/BaekJoon/Dltmd202/2869/Main.java | 28 ++++++++++++++++++ src/BaekJoon/Dltmd202/4153/Main.java | 43 ++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/BaekJoon/Dltmd202/2869/Main.java create mode 100644 src/BaekJoon/Dltmd202/4153/Main.java diff --git a/src/BaekJoon/Dltmd202/2869/Main.java b/src/BaekJoon/Dltmd202/2869/Main.java new file mode 100644 index 0000000..e16c634 --- /dev/null +++ b/src/BaekJoon/Dltmd202/2869/Main.java @@ -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; + } +} diff --git a/src/BaekJoon/Dltmd202/4153/Main.java b/src/BaekJoon/Dltmd202/4153/Main.java new file mode 100644 index 0000000..087abae --- /dev/null +++ b/src/BaekJoon/Dltmd202/4153/Main.java @@ -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 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 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); + } + } +}