본문 바로가기

코딩사이트 문제풀이/백준

백준 - 20953번

728x90

 

풀이

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

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int num           = 0;
            int cnt           = Integer.parseInt(br.readLine());

            while(num < cnt) {
                String[] strList = br.readLine().split(" ");
                int sendCnt   = Integer.parseInt(strList[0]) + Integer.parseInt(strList[1]);
                dolmen(sendCnt);
                num++;
            }
            
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void dolmen(int sendCnt) {
        int sum = 0;
        for(int j=1; j<sendCnt; j++) {
            sum += j;
        }
        System.out.println(sum * sendCnt);
    }
}

'코딩 문제 > 백준' 카테고리의 다른 글

백준 - 1920번  (0) 2026.03.03
백준 - 26005번  (0) 2024.03.10
백준 - 26004번  (0) 2024.03.10
백준 - 7576번  (1) 2024.02.25
백준 - 13460번  (0) 2023.06.18