본문 바로가기

Java465

[백준/Java] 2644번 촌수계산 -Codeimport java.io.*;import java.util.*;public class BOJ2644 { static ArrayList> nodes; static boolean[] visited; static int answer = 0; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); // visited 셋팅 visited = new bool.. 2026. 1. 25.
[백준/Java] 13549번 숨바꼭질 3 -Codeimport java.io.*;import java.util.*;public class BOJ13549 { static class Pos { int x, time; public Pos (int x, int time) { this.x = x; this.time = time; } } static boolean[] visited = new boolean[100001]; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStrea.. 2026. 1. 25.
[백준/Java] 1812번 사탕 -Codeimport java.io.*;import java.util.*;public class BOJ1812 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // x1 + x2 , x2 + x3 ..... xn + x1이므로 // 짝수 위치를 빼주면 결국 2x1로 첫번째 수만 남음 int now = 0; int[] sumCandy = new int[n]; for (int i = 0; i 처음에 sumCandys의 값으로 차를 구할 수 있을 거 같아서 해당 배열의 원소 간의 값 차.. 2026. 1. 25.
[백준/Java] 2573번 빙산 -Codeimport java.io.*;import java.util.*;public class BOJ2573 { static class Pos { int row, col; public Pos (int row, int col) { this.row = row; this.col = col; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pos pos = (.. 2026. 1. 24.
[백준/Java] 13913번 숨바꼭질 4 -Codeimport java.io.*;import java.util.*;public class BOJ13913 { static class Info { int pos, time; public Info(int pos, int time) { this.pos = pos; this.time = time; } } static Integer[] parents = new Integer[100001]; static { Arrays.fill(parents, null); } public static void main(String[] args) throws Exception { Buffere.. 2026. 1. 24.
[백준/Java] 7798번 Hotel -Codeimport java.io.*;import java.util.*;public class BOJ7798 { static class HotelInfo { int bedSize, capacity, rooms, price; String name; public HotelInfo(int bedSize, int capacity, int rooms, int price, String name) { this.bedSize = bedSize; this.capacity = capacity; this.rooms = rooms; this.price = price; this.name.. 2026. 1. 24.