hanker

백준(2292) JAVA - 벌집 본문

Study/ALGORITHM

백준(2292) JAVA - 벌집

hanker 2021. 1. 15. 10:15
반응형
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int tmp = 0;
		int cnt = 1;
		for(int i = 0 ; i < N ; i++) {
			tmp += i;
			if(N <= (6 * tmp) + 1 && N >= (6 * (tmp - i)) + 2) {
				cnt = i + 1;
				break;
			} 
		}
		System.out.println(cnt);
	}
}
반응형