Baekjoon Online Judge - 2292
Review
- 벌집은 ‘1-7-19-37…’ 즉, 6의 배수만큼 더해저 늘어난다.
Code (JAVA)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import java.util.*;
public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int input = sc.nextInt(); int six = 0; int room = 1; int count = 1; sc.close(); while (room < input) { six += 6; room += six; count ++; } System.out.println(count); } }
|