IT 정보/알고리즘(백준, BOJ)

[백준-BOJ] 2864

Dalyoung 2021. 2. 18. 22:22
728x90

www.acmicpc.net/problem/2864

 

2864번: 5와 6의 차이

첫째 줄에 두 정수 A와 B가 주어진다. (1 <= A,B <= 1,000,000)

www.acmicpc.net

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.doit();
    }
     
     
     
    public void doit() throws IOException{
       // System.setIn(new FileInputStream("input.txt"));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String [] input = br.readLine().split(" ");
        int min = Integer.parseInt(input[0].replaceAll("6", "5")) + Integer.parseInt(input[1].replaceAll("6", "5"));
        int max = Integer.parseInt(input[0].replaceAll("5", "6")) + Integer.parseInt(input[1].replaceAll("5", "6"));
        
        
        System.out.println(min + " " + max);
        br.close();
    }
}
728x90
반응형

'IT 정보 > 알고리즘(백준, BOJ)' 카테고리의 다른 글

[백준-BOJ] 2985  (0) 2021.02.24
[백준-BOJ] 2875  (0) 2021.02.18
[백준-BOJ] 2839  (0) 2021.02.18
[백준-BOJ] 2806  (0) 2021.02.18
[백준-BOJ] 2696  (0) 2021.02.15