• 문제 링크
2908번: 상수
상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두
www.acmicpc.net
• 풀이 코드
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));
bw.write(String.valueOf(Math.max(reverse(read()), reverse(read()))));
bw.flush();
}
private static int reverse(int n) {
return (n % 10 * 100) + (n / 10 % 10 * 10) + n / 100;
}
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' 카테고리의 다른 글
[백준] 2941 크로아티아 알파벳 - Implementation / Java (0) | 2024.04.19 |
---|---|
[백준] 1316 그룹 단어 체커 - Implementation / Java (0) | 2024.04.18 |
[백준] 1157 단어 공부 - Implementation / Java (0) | 2024.04.16 |
[백준] 11597 Excellence - Greedy / Java (0) | 2024.04.15 |
[백준] 27851 Watching Mooloo - Greedy / Java (0) | 2024.04.14 |
댓글