diff --git "a/JHLEE325/202603/21 BOJ G5 4\354\231\200 7.md" "b/JHLEE325/202603/21 BOJ G5 4\354\231\200 7.md" new file mode 100644 index 00000000..861aca69 --- /dev/null +++ "b/JHLEE325/202603/21 BOJ G5 4\354\231\200 7.md" @@ -0,0 +1,25 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int K = Integer.parseInt(br.readLine()); + + String binary = Integer.toBinaryString(K + 1); + + StringBuilder sb = new StringBuilder(); + for (int i = 1; i < binary.length(); i++) { + if (binary.charAt(i) == '0') { + sb.append('4'); + } else { + sb.append('7'); + } + } + + System.out.println(sb.toString()); + } +} +``` diff --git "a/JHLEE325/202603/22 BOJ G5 \352\260\204\354\204\240 \354\235\264\354\226\264\352\260\200\352\270\260 2.md" "b/JHLEE325/202603/22 BOJ G5 \352\260\204\354\204\240 \354\235\264\354\226\264\352\260\200\352\270\260 2.md" new file mode 100644 index 00000000..90380646 --- /dev/null +++ "b/JHLEE325/202603/22 BOJ G5 \352\260\204\354\204\240 \354\235\264\354\226\264\352\260\200\352\270\260 2.md" @@ -0,0 +1,77 @@ +```java +import java.io.*; +import java.util.*; + +class Node implements Comparable { + int target, weight; + + public Node(int target, int weight) { + this.target = target; + this.weight = weight; + } + + @Override + public int compareTo(Node o) { + return this.weight - o.weight; + } +} + +public class Main { + + static List[] adj; + static int[] dist; + static final int INF = Integer.MAX_VALUE; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int n = Integer.parseInt(st.nextToken()); + int m = Integer.parseInt(st.nextToken()); + + adj = new ArrayList[n + 1]; + for (int i = 1; i <= n; i++) adj[i] = new ArrayList<>(); + + for (int i = 0; i < m; i++) { + st = new StringTokenizer(br.readLine()); + int u = Integer.parseInt(st.nextToken()); + int v = Integer.parseInt(st.nextToken()); + int w = Integer.parseInt(st.nextToken()); + adj[u].add(new Node(v, w)); + adj[v].add(new Node(u, w)); + } + + st = new StringTokenizer(br.readLine()); + int s = Integer.parseInt(st.nextToken()); + int t = Integer.parseInt(st.nextToken()); + + dijkstra(n, s); + + System.out.println(dist[t]); + } + + static void dijkstra(int n, int start) { + dist = new int[n + 1]; + Arrays.fill(dist, INF); + + PriorityQueue pq = new PriorityQueue<>(); + dist[start] = 0; + pq.add(new Node(start, 0)); + + while (!pq.isEmpty()) { + Node current = pq.poll(); + int currNode = current.target; + int currWeight = current.weight; + + if (dist[currNode] < currWeight) continue; + + for (Node next : adj[currNode]) { + if (dist[next.target] > dist[currNode] + next.weight) { + dist[next.target] = dist[currNode] + next.weight; + pq.add(new Node(next.target, dist[next.target])); + } + } + } + } +} +```