Baekjoon Algorithm | Problem 15552: Fast A+B

Source

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

Problem

Solve Baekjoon Online Judge problem 15552, Fast A+B.

Input

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

Output

Print the answer required by the problem.

Sample Input 1

5 1 1 12 34 5 500 40 60 1000 1000

Sample Output 1

2 46 505 100 2000

Algorithm Classification

  • Math
  • Implementation
  • Arithmetic

Solution

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

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));
        ) {
            int n = Integer.parseInt(br.readLine());

            for (int i = 1; i <= n; i++) {
                String[] input = br.readLine().split(" ");
                final int a = Integer.parseInt(input[0]);
                final int b = Integer.parseInt(input[1]);
                bw.write((a + b) + "\n");
            }

            bw.flush();
        }
    }
}