Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- BAEKJOON
- codingtest
- Vue
- 코테
- DART
- 분할정복
- C++
- vuejs
- 안드로이드
- AndroidStudio
- 백준
- django
- 알고리즘
- DFS와BFS
- 파이썬
- 코딩테스트
- cos pro 1급
- Algorithm
- 동적계획법
- android
- 개발
- Flutter
- 코드품앗이
- Python
- 동적계획법과최단거리역추적
- issue
- DFS
- 안드로이드스튜디오
- cos
- cos pro
Archives
- Today
- Total
Development Artist
[COS Pro 1급, Python] 5차 1번 : 우리는 계단도 특별하게 오르죠 본문
728x90
반응형
문제 유형
빈칸
난이도
easy
Note
1. 수열 문제. 1 2 4 7 13 24 . . .
Code
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
def solution(n):
answer = 0
steps = [0 for _ in range(n+1)]
steps[1] = 1
steps[2] = 2
steps[3] = 4
for i in range(4, n+1):
steps[i] = steps[i-1] + steps[i-2] + steps[i-3]
print(steps)
answer = steps[n]
return answer
n1 = 3
ret1 = solution(n1)
print("solution 함수의 반환 값은", ret1, "입니다.")
n2 = 4
ret2 = solution(n2)
print("solution 함수의 반환 값은", ret2, "입니다.")
※ 가끔 코드 중 print(~)가 있습니다. 정리 못한 점 죄송합니다.
728x90
반응형
'Algorithm > COS' 카테고리의 다른 글
[COS Pro 1급, Python] 5차 3번 : 배열의 사전순 정렬 (0) | 2022.02.28 |
---|---|
[COS Pro 1급, Python] 5차 2번 : 물을 최대로 담고 싶어요 (0) | 2022.02.28 |
[COS Pro 1급, Python] 4차 10번 : 소수의 세제곱이 몇개가 있나요 (0) | 2022.02.25 |
[COS Pro 1급, Python] 4차 9번 : 분침과 시침의 각도 구하기 (0) | 2022.02.25 |
[COS Pro 1급, Python] 4차 8번 : n번째로 작은 수 구하기 (0) | 2022.02.25 |
Comments