Skip to content

Commit 3499d09

Browse files
committed
[level 2] Title: 2 x n 타일링, Time: 6.87 ms, Memory: 36.9 MB -BaekjoonHub
1 parent 3ef6fab commit 3499d09

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function solution(n) {
2+
const dp = new Array(n).fill(0);
3+
dp[0] = 1;
4+
dp[1] = 2;
5+
6+
for (let i = 2; i < n; i++) {
7+
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
8+
}
9+
10+
console.log(dp)
11+
return dp[n - 1];
12+
}
13+
14+
// 패턴을 구하다보면 피보나치 수열임을 알 수 있다
15+
// n = 1 >> 1
16+
// n = 2 >> 2
17+
// n = 3 >> 3
18+
// n = 4 >> 5
19+
// n = 5 >> 8
20+
// n = 6 >> 13
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# [level 2] 2 x n 타일링 - 12900
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12900)
4+
5+
### 성능 요약
6+
7+
메모리: 36.9 MB, 시간: 6.87 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 연습문제
12+
13+
### 채점결과
14+
15+
정확성: 70.0<br/>효율성: 30.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2025년 09월 18일 01:19:09
20+
21+
### 문제 설명
22+
23+
<p>가로 길이가 2이고 세로의 길이가 1인 직사각형모양의 타일이 있습니다. 이 직사각형 타일을 이용하여 세로의 길이가 2이고 가로의 길이가 n인 바닥을 가득 채우려고 합니다. 타일을 채울 때는 다음과 같이 2가지 방법이 있습니다.</p>
24+
25+
<ul>
26+
<li>타일을 가로로 배치 하는 경우</li>
27+
<li>타일을 세로로 배치 하는 경우</li>
28+
</ul>
29+
30+
<p>예를들어서 n이 7인 직사각형은 다음과 같이 채울 수 있습니다.</p>
31+
32+
<p><img src="https://i.imgur.com/29ANX0f.png" title="" alt="Imgur"></p>
33+
34+
<p>직사각형의 가로의 길이 n이 매개변수로 주어질 때, 이 직사각형을 채우는 방법의 수를 return 하는 solution 함수를 완성해주세요.</p>
35+
36+
<h5>제한사항</h5>
37+
38+
<ul>
39+
<li>가로의 길이 n은 60,000이하의 자연수 입니다.</li>
40+
<li>경우의 수가 많아 질 수 있으므로, 경우의 수를 1,000,000,007으로 나눈 나머지를 return해주세요.</li>
41+
</ul>
42+
43+
<hr>
44+
45+
<h5>입출력 예</h5>
46+
<table class="table">
47+
<thead><tr>
48+
<th>n</th>
49+
<th>result</th>
50+
</tr>
51+
</thead>
52+
<tbody><tr>
53+
<td>4</td>
54+
<td>5</td>
55+
</tr>
56+
</tbody>
57+
</table>
58+
<h5>입출력 예 설명</h5>
59+
60+
<p>입출력 예 #1<br>
61+
다음과 같이 5가지 방법이 있다.</p>
62+
63+
<p><img src="https://i.imgur.com/keiKrD3.png" title="" alt="Imgur"></p>
64+
65+
<p><img src="https://i.imgur.com/O9GdTE0.png" title="" alt="Imgur"></p>
66+
67+
<p><img src="https://i.imgur.com/IZBmc6M.png" title="" alt="Imgur"></p>
68+
69+
<p><img src="https://i.imgur.com/29LWVzK.png" title="" alt="Imgur"></p>
70+
71+
<p><img src="https://i.imgur.com/z64JbNf.png" title="" alt="Imgur"></p>
72+
73+
74+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges

0 commit comments

Comments
 (0)