본문 바로가기
BaekJoon/Bronze

[BOJ/JAVA] 백준 7891 : Can you add this? (자바)

by HoonSikE 2023. 10. 20.
반응형
SMALL
문제 정보
  문제명   - Can you add this?
  난이도   - 브론즈 V
문제 번호 - 7891번

문제 링크

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.

예제 입력/출력
예제 입력 예제 출력
4
-100 100
2 3
0 110101
-1000000000 1
0
5
110101
-999999999

알고리즘 분류
● 수학
● 구현
● 사칙연산


소스코드
package Lv1_Bronze;

import java.io.*;
import java.util.*;

/**
 * @author HanHoon
 * @category 수학, 구현, 사칙연산
 * https://www.acmicpc.net/problem/7891
 */
public class BOJ_B5_7891_Can_you_add_this {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = null;
        StringBuilder str = new StringBuilder();

        // N
        int N = Integer.parseInt(br.readLine());

        for (int n = 0; n < N; n++){
            st = new StringTokenizer(br.readLine());
            str.append(Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken())).append("\n");
        }
        System.out.print(str);
        br.close();
    }
}

 


BaekJoon List
 

BaekJoon List

BOJ Start!! ● [BOJ] 백준 회원가입, 시작하는 법 ● [BOJ] 등급(티어) 및 Solved.AC 적용 ● [BOJ/JAVA] 백준 소스코드 제출 시 유의사항(자바) Bronze ● Bronze V  - ● Bronze IV  - ● Bronze III  -..

han-hoon.tistory.com


  

기회는 준비된 자에게 찾아온다.

 


 

반응형
LIST

댓글