BackJoon Algorithm 뒤집힌 덧셈 1357 (Java)

업데이트:
최대 1 분 소요

BackJoon Algorithm - Java

alt

문제

alt

풀이

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Back_1357 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int X = Integer.parseInt(st.nextToken());
        int Y = Integer.parseInt(st.nextToken());

        System.out.println(Rev(Rev(X) + Rev(Y)));
        br.close();
    }

    public static int Rev(int num) {
        String str = "";
        while (num > 0) {
            str += num % 10;
            num /= 10;
        }
        return Integer.parseInt(str);
    }
}



댓글남기기