백준 2292 : 벌집

소스코드

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
#include <iostream>
using namespace std;
 
int main() {
 
    int index = 1// 몇 개의 방을 지나는지 체크
    int i = 0;    // 단계의 수
    int lev = 1// 총 방의 수
    int n;
 
    cin >> n; 
 
    while (true) {
 
        lev = lev + i * 6;
 
        if (n <= lev) {
            cout << index << endl;
            break;
        }
        i++;
        index++;
    }
}
 
 
 
cs

'BeakJoon' 카테고리의 다른 글

백준 4673 : 셀프 넘버  (0) 2020.08.28
백준 1193 : 분수 찾기  (0) 2020.08.28
백준 2775 : 부녀회장이 될테야  (0) 2020.08.28
백준 2750 : 수 정렬하기  (0) 2020.08.28
백준 2884 : 알람 시계 - JAVA  (0) 2020.08.13
TAGS.

Comments