알고리즘 스터디 2주차[구현2]

정재혁·2022년 1월 20일
0

[구현] 백준1292

쉽게 푸는 문제


[코드]

package implementation;

import java.util.ArrayList;
import java.util.Scanner;

public class Implementation_1292 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    //뭐가 문제지.??
        int N1 = sc.nextInt();
        int N2 = sc.nextInt();


        int sum =0;
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i =1;i<46;i++){
            for(int j=0;j<i;j++){
                arr.add(i);
            }
        }

        for(int i = N1-1;i<N2;i++){
            sum = sum + arr.get(i);
        }

        System.out.println(sum);
        sc.close();
    }
}
profile
저는 정재혁임니다^___^

0개의 댓글