알고리즘/일반(단순구현)
[백준] 2292번 벌집 #Java
VIPeveloper
2022. 5. 7. 19:57
728x90
반응형
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int [][] dp = new int[15][15];
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tc = Integer.parseInt(br.readLine());
int cnt = 2;
int endNumber = 0;
if(tc == 1){
System.out.println(1);
}else{
endNumber = 7;
// 마지막 숫자 범위 내에 있다면 cnt 만큼 떨어진 거리 내부에 있다는 증거이다.
while(tc > endNumber){
endNumber = endNumber + (6*cnt++);
}
System.out.println(cnt);
}
}
}
728x90
반응형