백준 풀이/자바(Java)
백준 3578 자바 - Holes
콘스_
2024. 4. 16. 09:30
// Holes
package Bronze_III_3;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Ex3578 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int h = Integer.parseInt(br.readLine());
int eight = h / 2;
h %= 2;
if (eight == 0 && h == 0) {
System.out.println(1);
} else if (eight == 0 && h == 1) {
System.out.println(0);
} else {
for (int i = 0; i < h; i++) {
System.out.print(4);
}
for (int i = 0; i < eight; i++) {
System.out.print(8);
}
}
}
}
구멍의 개수가 0과 1일때 말고는 4와 8만 이용하면 최소값을 구할 수 있다.