2024.06.13 ( Java )

changi123·2024년 6월 13일
0
post-thumbnail

1. 벌집 ( BaekJoon )

Math ( https://www.acmicpc.net/problem/2292 )

풀이 ->
package problem_solving.math;

import java.util.Scanner;

public class BaekJoon_2292 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		if(  n== 1) {
			System.out.println(1);
			return  ;
		}
		int first = 2; 
		int i = 1 ;
		while(true) {
			
			if( first+ ( (6*i) -1) < n  ) {
				first+= (6*i);
				i++;
			} else {
				break;
			}
			
			
		}
		
		System.out.println(i+1);
	}    

}

백준 레벨 변동

  • Gold 5 36% -> Gold 5 41%

풀이 유형

Math - 1문제

profile
개발자 홍찬기 꾸준한 사람이 되자

0개의 댓글

관련 채용 정보