본문 바로가기
Java/알고리즘

[Java] 백준 2292번 : 벌집

by EricJeong 2019. 8. 21.

 

 

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 6 + 12 + 18 + 24 ...  	
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		
		int sum = 1;
		int count = 1;
		while(sum < num) {
			sum += count++*6;
		}
		
		System.out.println(count);
	}
}

 

댓글