목록Algorithm (127)
main
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); int time = 0; for (char c : str.toCharArray()) { if ('A'
* 이분탐색 (Binary Search) import java.util.*; import java.io.*; public class Main { static int BinarySearch(int key, int low, int high, int[] arr) { if (low > high) return 0; int mid = (low + high) / 2; if (arr[mid] == key) { return 1; } else if (arr[mid] > key) { return BinarySearch(key, low, mid - 1, arr); } else if (arr[mid] < key) { return BinarySearch(key, mid + 1, high, arr); } return 0; } pu..
* 다이나믹 프로그래밍 * 그리디 알고리즘 import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int sugar = sc.nextInt(); int five_q = sugar / 5; int five_r = sugar % 5; int three_q = 0; while (true) { if (five_r == 1) { five_q -= 1; three_q += 2; } else if (five_r == 2) { five_q -= 2; three_q += 4; } else if (fiv..
* 감으로 품(왜 맞는지 생각해봐야 함) import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int A = sc.nextInt(); int B = sc.nextInt(); int V = sc.nextInt(); int record = 0; int day = 0; System.out.println((int) Math.ceil((double) (V - ..
* BufferedWriter 사용 import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int N = sc.nextInt(); int[] numbers = new int[N]; for (int i = 0; i < N; i++) { int num = sc.nextInt(); numbers[i] = num; } Arrays.sort(numbers); f..