문제

입력 및 출력

풀이
import java.io.*;
import java.util.*;
class Main {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] temp = br.readLine().split(" ");
int A = Integer.parseInt(temp[0]);
int B = Integer.parseInt(temp[1]);
ArrayList<Integer> list = new ArrayList<>();
for(int i = 1; i <= 1000; i++) {
for(int j = 0; j < i; j++) {
list.add(i);
}
}
int result = 0;
for(int i = A; i <= B; i++) {
result += list.get(i - 1);
}
System.out.println(result);
}
}
결과 및 해결방법
[결과]
