• 문제 링크
https://www.acmicpc.net/problem/4363
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
br.readLine();
String s;
double d = 0;
while ((s = br.readLine()) != null) d += calc(s);
int i = (int) Math.round(d * 6 / 1000);
sb.append(i / 60).append(":").append(i % 60 < 10 ? "0" : "").append(i % 60);
bw.write(sb.toString());
bw.flush();
}
private static double calc(String s) {
String[] a = s.split(" ");
return Math.sqrt(Math.pow(Integer.parseInt(a[2]) - Integer.parseInt(a[0]), 2) + Math.pow(Integer.parseInt(a[3]) - Integer.parseInt(a[1]), 2));
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 4556 Relative Relatives - Graph Theory / Java (0) | 2024.08.16 |
---|---|
[백준] 29865 Kahe käigu ratsu - Graph Theory / Java (0) | 2024.08.15 |
[백준] 6752 Time on task - Greedy / Java (0) | 2024.08.13 |
[백준] 13472 Sticky Situation - Greedy / Java (0) | 2024.08.12 |
[백준] 23895 Allocation - Greedy / Java (0) | 2024.08.11 |
댓글