Created
June 16, 2021 06:59
-
-
Save Kernelzero/446927fa2f76415647d4f9c5c17ba008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# codeup 2641 | |
# 숏다리의 계단 오르기 | |
N = int(input()) | |
count = 0 | |
def climb(remains, penalty): | |
global count | |
if remains == 0: | |
# 결과값 반환 | |
count += 1 | |
return | |
elif remains < 0: | |
return | |
else: | |
if penalty <= 0: | |
penalty = 0 | |
if penalty == 0: | |
# 모든 칸만큼 올라갈 수 있음 | |
climb(remains - 1, penalty - 1) | |
climb(remains - 2, penalty - 1) | |
climb(remains - 3, 2) | |
else: | |
climb(remains - 1, penalty - 1) | |
climb(remains - 2, penalty - 1) | |
climb(N, 0) | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment