문제
풀이 (Java)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public class Main{ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int target = sc.nextInt(); int cnt = 1; int range = 1; int tmp = 1; while(true) { if(range >= target) { break; } tmp = 6*(cnt++); range += tmp; } System.out.println(cnt); } } | cs |
2칸 - 2~7
3칸 - 8~19
4칸 - 20~37
5칸 - 38~61
6 - 12 - 18 - 24 크기로 범위가 커지는 규칙을 찾을 수 있다.
문제 출처
'프로그래밍 > Baekjoon' 카테고리의 다른 글
(파이썬) 백준 알고리즘 10422번 괄호 (0) | 2019.05.24 |
---|---|
(자바) 백준 알고리즘 10250번 ACM 호텔 (0) | 2019.04.11 |
(파이썬) 백준 알고리즘 5622번 다이얼 (2) | 2019.04.01 |
(파이썬) 백준 알고리즘 2908번 상수 (0) | 2019.02.25 |
(파이썬) 백준 알고리즘 1316번 그룹 단어 체커 (0) | 2019.02.25 |