A Plus B

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 5.0s
Memory limit: 256M

Problem type

You are given two integers, a and b. Output the sum of the two integers.

Input Specification

The first line will contain an integer N (1 \le N \le 100\,000), the number of addition problems Tudor needs to do. The next N lines will each contain two space-separated integers whose absolute value is less than 1\,000\,000\,000, the two integers Tudor needs to add.

Output Specification

Output N lines of one integer each, the solutions to the addition problems in order.

Sample Input

2
1 1
-1 0

Sample Output

2
-1

Example Solutions

The judge is strict in expecting the output to match exactly. Do not prompt for input.

Python 2

N = int(raw_input())

for _ in xrange(N):
    a, b = map(int, raw_input().split())
    print a + b

Python 3

N = int(input())

for _ in range(N):
    a, b = map(int, input().split())
    print(a + b)

Java

import java.util.*;

public class APlusB {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();
        for (int i = 0; i < N; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a + b);
        }
    }
}

C++

#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

C

#include <stdio.h>

int main() {
    int N;
    scanf("%d\n", &N);

    for (int i = 0; i < N; i++) {
        int a, b;
        scanf("%d %d\n", &a, &b);
        printf("%d\n", a + b);
    }
}

Comments

There are no comments at the moment.