• 문제 링크
https://www.acmicpc.net/problem/34723
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int p = read(), m = read(), c = read(), x = read(), min = Integer.MAX_VALUE;
for (int i = 1; i <= p; i++)
for (int j = 1; j <= m; j++)
for (int k = 1; k <= c; k++) min = Math.min(min, Math.abs((i + j) * (j + k) - x));
bw.write(String.valueOf(min));
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}'Problem Solving > Baekjoon' 카테고리의 다른 글
| [백준] 19741 Patterns - Brute Force / Java (0) | 2025.11.13 |
|---|---|
| [백준] 5205 School Colors - Brute Force / Java (0) | 2025.11.12 |
| [백준] 19532 수학은 비대면강의입니다 - Brute Force / Java (0) | 2025.11.10 |
| [백준] 30580 Natatorium - Data Structure / Java (0) | 2025.11.09 |
| [백준] 11346 Cornell Party - Retry - Data Structure / Java (0) | 2025.11.08 |
댓글