[백준] 2292번 : 벌집 - C

강재원·2022년 10월 7일
0

[코딩테스트] C/C++

목록 보기
107/200



https://www.acmicpc.net/problem/2292

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    int n;
    scanf("%d",&n);
    int a=1;
    int t=1;
    if(n==1) printf("1");
    else{
        while(1){
            if(n<a){
                printf("%d",t);
                break;
            }
            else if(n==a){
                printf("%d",t);
                break;
            }
            a+=6*t;
            t++;
        }
    }
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글