20421 [백준] 자바 문제 풀이 2042 : 골드1 BOJ 2042 : 구간 합 구하기 풀이 코드 import java.io.*; import java.util.*; public class Main { static class SegmentTree { private long[] tree; SegmentTree(int n){ double height = Math.ceil(Math.log(n)/Math.log(2))+1; long size = Math.round(Math.pow(2, height)); tree = new long[Math.toIntExact(size)]; } long init(long[] arr, int node, int start, int end) { if(start == end) return tree[node] = arr[start]; re.. 2023. 10. 4. 이전 1 다음 728x90 반응형