Dev.baelanche
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/yxlEG/btquI2naju6/K0fguqgjFaXqmlnGmB9db0/img.png)
우리가 구해야 하는 것은 면의 수 이고 주어진 식을 활용하면 된다. 면의 수가 x 일때 v - e + x = 2 x = e - v + 2 이다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int v = sc.nextInt(); int e = sc.nextInt(); System.out.println(2 - v + e); } } }
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/szptM/btquFdjkTDk/pYWPQatmKX9oLef5kUuzb1/img.png)
문제에 기재되어 있는 (멜로디 개수 / 앨범 곡 개수) = 평균값(반올림) 을 거꾸로 해주면된다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int i = sc.nextInt(); System.out.println((a * (i-1)) + 1); } } 머리 쉬려고 풀었다..ㅎㅎ
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ct4Vjs/btquGEgJdGq/LzBMYn1fqwOZEQkaTNAgFk/img.png)
좌측에 주어진 수부터 테이프로 메꾼다. 테이프는 -0.5, +0.5 만큼 덮어야하므로 구멍의 위치가 1, 2 테이프 길이가 1이면 2개가 있어야 모두 덮을 수 있다. 따라서 범위 조건은 1
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/HqzVH/btquI1BMJUp/ta0KsWJNQlr2OQnVaCi2N1/img.png)
캠핑장 이용일 수를 최대로 하기 위해, 전체 휴가 수에서 캠핑 이용일 수를 빼고 캠핑장 이용 불가능 한 수를 번갈아 빼며 진행한다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int c = 1; while(true) { int l = sc.nextInt(); int p = sc.nextInt(); int v = sc.nextInt(); if(l == 0 && p == 0 && v == 0) break; int use = 0; while(true) { if(v >= l) { v -= l; use += l; } else { use += v; v = 0; } v -= p - l;..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bNEWo0/btquIPO6Vee/h76sXndue7SiBB7ZpCuUXk/img.png)
일반적인 BFS 탐색에서 조건을 잘 주면 된다. A 버튼을 눌렀을때는 99999를 넘지않게한다. B 버튼을 눌러 2배가 되었을때 99999가 넘는다면 그 경우는 통과한다. public class Main { static int t; static int g; static int max = 100000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); t = sc.nextInt(); g = sc.nextInt(); int ans = bfs(n); System.out.println(ans == -1 ? "ANG" : ans); } public static int bfs(int n)..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/JJYpg/btquCZTzQb2/bNS9peTIf5RWSV7Z2t2Fok/img.png)
주어진 수에 6이 포함되면 5로 바꿔 최소값을 합치고, 5가 포함되면 6으로 바꿔 최대값끼리 합치면 된다. A, B 를 어떤 형태로 받던 상관없이 수만 잘 바꾸어주면 된다. 아래 코드에서는 정수로 받아 10으로 나누면서 각 자리수에 접근했다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println((makeMin(a) + makeMin(b)) + " " + (makeMax(a) + makeMax(b))); } public static int makeMin(int a) { St..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/4BdQW/btquDBxQmTP/sFT0I8nOYhz2xNWKXisaXK/img.png)
1차원 배열에서 BFS 순회한다. 수빈이는 뒤로도 이동할 수 있으므로 동생과 못 만날 경우는 없다. 이동 조건이 {-1, 1, 2*x} 인 것만 유의하자. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int a[] = new int[100001]; boolean visited[] = new boolean[100001]; Queue queue = new LinkedList(); queue.offer(n); visited[n] = true; a[n] = 0; while(!queue.isEmpty()) ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/eKzlOZ/btquCLVrf8Q/zREKrGNIvFz0pRYaIsPYq0/img.png)
1차원 배열에서 방문 이력을 기록하면서 이동하는 문제이다. 변수 D 를 음수로 쓰는것만 까먹지 않으면 된다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int f = sc.nextInt(); int s = sc.nextInt(); int g = sc.nextInt(); int u = sc.nextInt(); int d = sc.nextInt(); Queue queue = new LinkedList(); int a[] = new int[f+1]; boolean visited[] = new boolean[f+1]; int mx[] = {u, -d}; boolean success..