티스토리 뷰

PS/백준

2292번 벌집

unside 2019. 6. 24. 11:26

백준 2292번

문제 사이트 :
https://www.acmicpc.net/problem/2292

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(void) {
	int input;
	scanf("%d", &input);
	if (input == 1) {
		printf("1");
	}
	else {
		int n = 1;
		while (1) {
			if (3 * n * n - 3 * n + 2 <= input && input <= 3 * n * n + 3 * n + 1) {
				printf("%d", n+1);
				break;
			}
			n++;
		}
	}
	return 0;
}

'PS > 백준' 카테고리의 다른 글

2775번 부녀회장이 될테야  (0) 2019.06.24
1193번 분수찾기  (0) 2019.06.24
11654번 아스키 코드  (0) 2019.06.24
10809번 알파벳 찾기  (0) 2019.06.24
10039번 평균 점수  (0) 2019.06.24
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
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
글 보관함