목록백준(java) (15)
보라코딩

정렬을 이용해 풀어야 한다고 생각했는데꼭 그러지 않아도 되었다. import java.util.*;import java.io.*;public class Main{ // 공주님의 정원 (그리디) public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); StringTokenizer st; Listint[]> flowers = new ArrayList(); f..

처음으로 풀어본 dp문제젤 정답율 높은 거 골랐다.대략 어떤 느낌인지 알겠다..! 정수 삼각형import java.util.*;import java.io.*;public class Main{ static int N; static int[][] arr; static int[][] dp; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; N = Integer.parseInt(br.readLine()); arr ..

높이가 1부터 100이라고 해서 처음에 1~100을 다 탐색하려고 했는데maxHeight를 구하는 것으로 변경했고1부터 탐색하면 틀리고 0부터 탐색해야 한다! 그리고 visited와 count 초기화에 주의 필요! import java.util.*;import java.io.*;public class Main{ static int N; static int[][] array; static boolean[][] visited; static int[] dx = {-1,1,0,0}; static int[] dy = {0,0,-1,1}; public static void main(String[] args) throws IOException { Buffered..

단지번호붙이기 import java.util.*;import java.io.*;public class Main{ static int N; static int[][] array; static boolean[][] visited; static int count; static int[] dx = {-1,1,0,0}; static int[] dy = {0,0,-1,1}; static ListInteger> result; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.i..

import java.util.*;import java.io.*;public class Main{ static int node; static int line; static int[][] array; static boolean[] visited; static int count; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); node = Intege..

import java.io.*;import java.util.*;public class Main { static ArrayListInteger>[] list; // 리스트의 배열 static boolean[] visited; 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()); ..

import java.util.*; public class Main{ static int N; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); // 일의 자리 소수는 2, 3, 5, 7 이므로 여기서 부터 시작! (한자리수 시작) DFS(2, 1); DFS(3, 1); DFS(5, 1); DFS(7, 1); } static void DFS(int num, int jarisu){ if(jaris..

import java.util.*;import java.io.*;public class Main { static ArrayList[] A; static boolean[] visited ; 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 ..
BaaaaaaaaaaarkingDog의 공개 문제집 - 1 페이지 www.acmicpc.net

문제집: 너무 어렵지 않은 완전 탐색 (ilyoan) www.acmicpc.net 일곱 난쟁이 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] height = new int[9]; int sum = 0; for(int i = 0; i