• 문제 링크
https://www.acmicpc.net/problem/1292
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int a = read(), b = read() + 1, k = 1;
        int[] arr = new int[b];
        for (int i = 1; i < b; i++) for (int j = 0; j < i && k < b; j++) arr[k++] = i;
        int sum = 0;
        for (int i = a; i < b; i++) sum += arr[i];
        bw.write(String.valueOf(sum));
        bw.flush();
    }
    private static int read() throws IOException {
        int c, n = System.in.read() & 15;
        while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
        return n;
    }
}'Problem Solving > Baekjoon' 카테고리의 다른 글
| [백준] 1357 뒤집힌 덧셈 - Implementation / Java (0) | 2024.08.31 | 
|---|---|
| [백준] 10820 문자열 분석 - Implementation / Java (0) | 2024.08.30 | 
| [백준] 1076 저항 - Implementation / Java (0) | 2024.08.28 | 
| [백준] 1159 농구 경기 - Implementation / Java (0) | 2024.08.27 | 
| [백준] 1100 하얀 칸 - Implementation / Java (0) | 2024.08.26 | 
 
										
									 
										
									 
										
									 
										
									
댓글