목록Algorithm (127)
main
* 색종이를 붙이는 판을 배열로 구현했다. import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int[][] board = new int[100][100]; for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { board[j][i] = 0; } } int N = scan.nextInt(); for (int k = 0; k < N; k++) { int x1 = scan.nextInt(); int y1 = scan.next..
* 출발점/도착점 중 하나만 원 내부에 있는 경우만 count를 센다. * 하나의 원 안에 출발점과 도착점이 모두있는 경우에는, 원을 지나지 않고 도착할 수 있으므로 count를 세지 않는다. * 기하학 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int T = scan.nextInt(); for (int i = 0; i < T; i++) { int x1 = scan.nextInt(); int y1 = scan.nextInt(); int x2 = scan.nextInt()..
* 다이나믹 프로그래밍 (DP) import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int[][] arr = new int[15][15]; for (int i = 0; i 0) { arr[j][i] = arr[j - 1][i] + a..
* 빈도값을 저장하기 위해서 HashMap 사용 * 반올림 Math.round import java.io.*; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int[] numbers = new int[N]; Map map = new HashMap(); long sum = 0; int max_freq = 1; for (int i = 0; i < N; i++) { int num = scan.nextInt(); int ..
import java.io.*; import java.util.*; public class Main { static long total = 0; public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int[] arr = new int[N]; for (int i = 0; i < N; i++) { arr[i] = scan.nextInt(); } int B = scan.nextInt(); int C = scan.nextInt(); for (int i = 0; i < arr.length; i++) { int num = arr[i]; if (num ..