백준 c++ 2292 벌집

jaranda·2022년 1월 28일
0

2292 벌집

문제풀이

#include <iostream>
using namespace std;
void fast_io(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
    fast_io();
    int a, b = 1, i;

    cin >> a;

    for (i = 1; a > b; i++)
    {
        b += 6 * i;
    }
    cout << i;
}

가운데 1부터 시작해서 몇번째 그룹에 있는지 찾는다. 1 7 19 37 은 6의 배수로 커지기때문에 그걸 이용한다.

profile
자라는 개발자

0개의 댓글