문제설명 소스코드 DFS풀이(스택) import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; import java.util.StringTokenizer; public class Main { static int N; //vertex static int M; //edge static int V; //첫 탐색 static boolean visited[]; //방문 표시 static int vertex[][]; //인접 행렬 static int count = 0; //감염된 컴퓨터 수 static void DFS(int V) //첫 탐색 위치를 매개변수로 받음 { Stack stack = new Stack();..
문제설명 소스코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; import java.util.StringTokenizer; public class Main { static int N; //vertex static int M; //edge static int V; //첫 탐색 static boolean visited[]; //방문 표시 static int vertex[][]; //인접 행렬 static StringBuilder sb = new StringBuilder(); static void DFS..
문제설명 소스코드 import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int arr[] = new int[10]; int sum = 0; for(int i = 0; i 100) { if(Math.abs(100-temp) >= Math.abs(100-sum)) System.out.print(sum); else System.ou..
문제설명 소스코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Comparator; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { PriorityQueue absHeap = new PriorityQueue(new Comparator() { @Override public int compare(Integer o1, Integer o2) { if(Math.abs(o1) == Math.abs(o2)) return Integer.compare(o1, o2); //절..
문제설명 소스코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Collections; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { PriorityQueue maxHeap = new PriorityQueue(Collections.reverseOrder()); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder()..
문제설명 소스코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { PriorityQueue maxHeap = new PriorityQueue(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int N = Integer.parseInt(br.readLine()); for(int i = 0..
문제설명 소스코드 import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); while(sc.hasNextInt()) { int n = sc.nextInt(); int k = sc.nextInt(); int ans = n; int stamps; while(n >= k) { stamps = n / k; ans += stamps; n = stamps + (n % k); } System.out.println(ans); } } } 설명 코드가 간단하기 때문에 코드에 대한 설명은 필요없을 것 같다. 문제를 보면 테스트케이스..
문제설명 소스코드 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static int priority(char operator) { if (operator == '+' || operator == '-') return 1; if (operator == '*' || operator == '/') return 2; return 0; } public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(Syst..