Baekjoon Algorithm | Problem 2908: Constant
Source
https://www.acmicpc.net/problem/2908
Problem
Solve Baekjoon Online Judge problem 2908, Constant.
Input
Follow the input format and constraints given in the original problem statement.
Output
Print the answer required by the problem.
Sample Input 1
734 893
Sample Output 1
437
Sample Input 2
221 231
Sample Output 2
23 45
Sample Input 3
839 237
Sample Output 3
938
Algorithm Classification
- Math
- Implementation
Solution
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String[] input = br.readLine().split(" ");
int a = Integer.parseInt(new StringBuffer(input[0]).reverse().toString());
int b = Integer.parseInt(new StringBuffer(input[1]).reverse().toString());
if(a > b) {
System.out.println(a);
} else {
System.out.println(b);
}
}
}
}