-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from Kut-PS-Study/Dltmd202
Feat: Add solution of #118
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |