Baekjoon Algorithm | Problem 10952: A+B - 5

Source

https://www.acmicpc.net/problem/10952

Problem

Solve Baekjoon Online Judge problem 10952, A+B - 5.

Input

Follow the input format and constraints given in the original problem statement.

Output

Print the answer required by the problem.

Sample Input 1

1 1 2 3 3 4 9 8 5 2 0 0

Sample Output 1

2 5 7 17 7

Algorithm Classification

  • Math
  • Implementation
  • Arithmetic

Solution

import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        try (
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        ) {
            while (true) {
                String[] input = br.readLine().split(" ");
                final int a = Integer.parseInt(input[0]);
                final int b = Integer.parseInt(input[1]);

                if(a == 0 && b == 0) {
                    break;
                }
                bw.write((a + b) + "\n");
            }

            bw.flush();
        }
    }
}