https://www.acmicpc.net/problem/7891
7891번: Can you add this?
The input contains several test cases. The first line contains and integer t (t ≤ 100) denoting the number of test cases. Then t tests follow, each of them consisiting of two space separated integers x and y (−109 ≤ x, y ≤ 109).
www.acmicpc.net
문제
Given two integers, calculate and output their sum.
입력
The input contains several test cases. The first line contains and integer t (t ≤ 100) denoting the number of test cases. Then t tests follow, each of them consisiting of two space separated integers x and y (−109 ≤ x, y ≤ 109).
출력
For each test case output output the sum of the corresponding integers.
예제 입력 1
4
-100 100
2 3
0 110101
-1000000000 1
예제 출력 1
0
5
110101
-999999999
코드
const input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n');
const n = Number(input[0]);
const result = [];
for(let i = 1; i <= n; i++){
const [x, y] = input[i].split(' ').map(Number);
result.push(x + y);
}
console.log(result.join('\n'));
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 9772: Quadrants / Node.js (JavaScript) (0) | 2023.04.28 |
---|---|
[백준] 8437: Julka / Node.js (JavaScript) (0) | 2023.04.28 |
[백준] 5341: Pyramids / Node.js (JavaScript) (0) | 2023.04.27 |
[백준] 11729: 하노이 탑 이동 순서 / Node.js (JavaScript) (0) | 2023.04.27 |
[백준] 11719: 그대로 출력하기 2 / Node.js (JavaScript) (0) | 2023.04.27 |
댓글