diff --git a/LeeTaeHo/boj/boj11037.java b/LeeTaeHo/boj/boj11037.java new file mode 100644 index 00000000..ba4e7659 --- /dev/null +++ b/LeeTaeHo/boj/boj11037.java @@ -0,0 +1,40 @@ +import java.io.*; +import java.util.*; + +public class boj11037 { + static boolean[] visited = new boolean[10]; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringBuilder sb = new StringBuilder(); + String s = ""; + while((s = br.readLine()) != null){ + int n = Integer.parseInt(s); + int result = 0; + while(++n <= 999_999_999){ + if(isDuplicate(n)){ + result = n; + break; + } + + } + sb.append(result).append("\n"); + } + System.out.println(sb); + } + + static boolean isDuplicate(int n){ + Arrays.fill(visited, false); + while(n > 0){ + int digit = n % 10; + if(digit == 0) return false; + if(visited[digit]){ + return false; + }else{ + visited[digit] = true; + } + n /= 10; + } + return true; + } +} diff --git a/LeeTaeHo/boj/boj14226.java b/LeeTaeHo/boj/boj14226.java new file mode 100644 index 00000000..19dbd7d5 --- /dev/null +++ b/LeeTaeHo/boj/boj14226.java @@ -0,0 +1,56 @@ +import java.io.*; +import java.util.*; + +public class boj14226 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int s = Integer.parseInt(br.readLine()); + + System.out.println(getEmoticons(s)); + } + + static int getEmoticons(int s){ + boolean[][] visited = new boolean[1004][1004]; + Queue q = new LinkedList<>(); + q.offer(new Node(1, 0, 0)); + visited[1][0] = true; + while(!q.isEmpty()){ + Node node = q.poll(); + + int cnt = node.cnt; + int buffer = node.buffer; + int time = node.time; + + if(cnt == s) return time; + + if(cnt - 1 >= 0 && !visited[cnt - 1][buffer]){ + visited[cnt - 1][buffer] = true; + q.offer(new Node(cnt - 1, buffer, time + 1)); + } + + if(buffer + cnt <= 1000 && !visited[cnt][cnt]){ + visited[cnt][cnt] = true; + q.offer(new Node(cnt, cnt, time + 1)); + } + + if(buffer != 0 && cnt + buffer <= 1000 && !visited[cnt + buffer][buffer]){ + visited[cnt + buffer][buffer] = true; + q.offer(new Node(cnt + buffer, buffer, time + 1)); + } + } + return 0; + } + + static class Node{ + int cnt; + int buffer; + int time; + + public Node(int cnt, int buffer, int time) { + this.cnt = cnt; + this.buffer = buffer; + this.time = time; + } + } +} diff --git a/LeeTaeHo/boj/boj23829.java b/LeeTaeHo/boj/boj23829.java new file mode 100644 index 00000000..e1c2fb5d --- /dev/null +++ b/LeeTaeHo/boj/boj23829.java @@ -0,0 +1,52 @@ +import java.io.*; +import java.util.*; + +public class boj23829 { + 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 q = Integer.parseInt(st.nextToken()); + + int[] arr = new int[n]; + long[] prefix = new long[n + 1]; + + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + + Arrays.sort(arr); + + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + arr[i]; + } + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < q; i++) { + int p = Integer.parseInt(br.readLine()); + int idx = binarySearch(arr, p); + + sb.append((prefix[n] - prefix[idx] - ((long) p * (n - idx))) + (Math.abs(prefix[idx] - ((long) p * idx)))).append("\n"); + } + System.out.println(sb); + } + + static int binarySearch(int[] arr, int p){ + int left = 0; + int right = arr.length; + + while(left < right){ + int mid = (left + right) / 2; + + if(arr[mid] < p){ + left = mid + 1; + }else{ + right = mid; + } + } + return right; + } +} \ No newline at end of file diff --git a/LeeTaeHo/boj/boj25795.java b/LeeTaeHo/boj/boj25795.java new file mode 100644 index 00000000..831567e6 --- /dev/null +++ b/LeeTaeHo/boj/boj25795.java @@ -0,0 +1,36 @@ +import java.io.*; +import java.util.*; + +public class boj25795 { + static final int MOD = 100000; + static int n, b, c; + static long max; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + n = Integer.parseInt(st.nextToken()); + int a = Integer.parseInt(st.nextToken()); + b = Integer.parseInt(st.nextToken()); + c = Integer.parseInt(st.nextToken()); + + max = 0; + + dfs(a + b,1, 0, 1); + System.out.println(max); + } + + static void dfs(long result, int white, int dark, int depth){ + if(depth == n + n){ + if(result > max ) max = result; + return; + } + + if(white != n){ + dfs((result + b) % MOD, white + 1, dark, depth + 1); + } + if(white > dark && dark != n){ + dfs((result * c) % MOD, white, dark + 1, depth + 1); + } + } +} \ No newline at end of file