Notice
Recent Posts
Recent Comments
Link
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준-2292번/Java] 벌집 본문

Algorithm

[백준-2292번/Java] 벌집

1984 2022. 11. 10. 15:29
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int honeyHouse = 1;
		int d = 6;
		int d_cnt = 1;
		while (true) {
			if (honeyHouse >= N)
				break;
			honeyHouse += d * d_cnt;
			d_cnt++;
		}

		System.out.println(d_cnt);

		sc.close();
	}

}
728x90

'Algorithm' 카테고리의 다른 글

[백준-15552번/Java] 빠른 A+B  (0) 2022.11.10
[백준-10757번/Java] 큰 수 A + B  (0) 2022.11.10
[백준-1712번/Java] 손익분기점  (0) 2022.11.10
[백준-1065번/Java] 한수  (0) 2022.11.10
[백준-4673번/Java] 셀프 넘버  (0) 2022.11.10
Comments