Skip to content

Commit c68e556

Browse files
committed
백준 11726번 2×n 타일링
문제 링크: https://www.acmicpc.net/problem/11726
1 parent 3c924cc commit c68e556

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
from typing import List
3+
4+
5+
def solve():
6+
N = int(sys.stdin.readline().strip())
7+
dp: List[int] = [0 for _ in range(N + 1)]
8+
9+
dp[0] = 0
10+
dp[1] = 1
11+
if N == 1:
12+
print(dp[N])
13+
return
14+
15+
dp[2] = 1 + dp[1]
16+
if N == 2:
17+
print(dp[N])
18+
return
19+
20+
for i in range(3, N + 1):
21+
dp[i] = (dp[i-1] + dp[i-2]) % 10007
22+
23+
print(dp[N])
24+
25+
26+
if __name__ == '__main__':
27+
solve()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
55
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
from pathlib import Path
3+
from unittest import TestCase
4+
from main import solve
5+
6+
7+
class Test(TestCase):
8+
def my_solve(self, testcase_input):
9+
sys.stdin = open(testcase_input, 'r')
10+
stdout = sys.stdout
11+
sys.stdout = open('stdout.txt', 'w')
12+
solve()
13+
sys.stdout.close()
14+
sys.stdout = stdout
15+
16+
def test_solve(self, testcase_number: str):
17+
self.my_solve('test' + testcase_number + '.txt')
18+
self.assertEqual(
19+
Path('test' + testcase_number + '_answer.txt').read_text().strip(),
20+
Path('stdout.txt').read_text().strip())
21+
22+
def test1_solve(self):
23+
self.test_solve('1')
24+
25+
def test2_solve(self):
26+
self.test_solve('2')

0 commit comments

Comments
 (0)