본문 바로가기
Algorithm/Baekjoon For.Java

2292 : 벌집

by Jinny zinny 2023. 3. 20.
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
		
		int N=Integer.parseInt(br.readLine());
		
		int SP=2;
		int EP=7;
		
		if(N==1) {
			bw.write("1");
		} else {
			int count=1;
			while(!(SP<=N&&N<=EP)) {
				
				SP+=(count*6);
				EP+=((count+1)*6);
				count+=1;
			}
			bw.write(String.valueOf(count+1));
		}		
		bw.flush();
	}
}
반응형

'Algorithm > Baekjoon For.Java' 카테고리의 다른 글

11723 : 집합  (0) 2023.03.22
1676 : 팩토리얼 0의 갯수  (0) 2023.03.22
1354 : 무한 수열 2  (0) 2023.03.20
10816 : 숫자 카드 2  (0) 2023.03.17
1351 : 무한 수열  (0) 2023.03.16