2292 : 벌집

2292 : 벌집

반응형

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

import java.util.Scanner; public class Main2292 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); //2 8 20 38 62 // 6 12 18 24 int count = 1; int room = 2; if (a == 1) { System.out.println(1); }else { while(room <= a) { room = room +(6*count); count++; } System.out.println(count); } } }

반응형

from http://eugeen.tistory.com/54 by ccl(A) rewrite - 2021-11-30 10:02:25