[백준 10844] 쉬운 계단 수 #90
ghdcksgml1
started this conversation in
1일 1알고리즘
Replies: 1 comment
-
|
dp문제는 그저 아이디어 싸움.. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
DP만 하면 알고리즘이 하기 싫어지네;;
아이디어
숫자가 0일때는 그다음 계단수가 1밖에 안나오고, 숫자가 9일때는 그다음 계단수가 8밖에 안되기 때문에 1~8 구간과 다른 처리를 해줘야한다.
그래서 다음 계단수가 0일때의 개수는 현재 계단수의 1값을, 다음 계단수가 9일때에는 현재 계단수의 8값을 넣었고,
다음 계단수가 1~8 구간일때에는 가려고 하는 계단수를 A라고 했을때, 현재 계단수 A-1, A+1을 더한 값을 넣어준다.
시간복잡도
O(100 * 10)
소스코드
Beta Was this translation helpful? Give feedback.
All reactions