• 문제 링크
https://www.acmicpc.net/problem/2576
• 풀이 코드
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 sum = 0, min = 100;
for (int i = 0; i < 7; i++) {
int n = read();
if ((n & 1) == 0) continue;
sum += n;
min = Math.min(min, n);
}
bw.write(sum == 0 ? "-1" : sum + "\n" + 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' 카테고리의 다른 글
| [백준] 5134 Grocery Shopping - Data Structure / Java (0) | 2025.12.27 |
|---|---|
| [백준] 14670 병약한 영정 - Data Structure / Java (0) | 2025.12.26 |
| [백준] 34692 아 마이마이 하고 싶다 - Data Structure / Java (0) | 2025.12.25 |
| [백준] 30949 Equal Schedules - Data Structure / Java (0) | 2025.12.24 |
| [백준] 25757 임스와 함께하는 미니게임 - Data Structure / Java (0) | 2025.12.23 |
댓글