알고리즘왕/BOJ

[백준/2292/JAVA] 벌집

찌 ㅋ 2020. 3. 18. 20:38

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(solution(x));
	}
	static int solution(int x) {
		int result = 1;
		int range = 1;
		while(range < x) {
			range += 6*result;
			result++;
		}
		return result;
	}
}