Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 29 | 30 |
Tags
- error
- ํ ์ดํ๋ก์ ํธ
- fe
- heapq
- mongodb
- node.js
- ์ฝ๋ฉ
- javascript
- ์ฝ๋ฉ์ ํ
- ๋ชจ๊ฐ์ฝ
- ์๊ณ ๋ฆฌ์ฆ
- ๋๋ฆผ์ฝ๋ฉ
- CSS
- JS
- ๊ตญ๋น์ง์
- ํ์ด์ฌ
- ์ฝ๋ฉํ ์คํธ
- ํ๋ก์ ํธ
- ๋ฐฑ์ค
- ํ๋ก๊ทธ๋๋จธ์ค
- KDT
- ํ๋ก ํธ์๋
- ๋ ธ๋ง๋์ฝ๋
- ๊ฐ๋ฐ
- Til
- react
- ํฌ๋กค๋ง
- HTML
- ๊ทธ๋ฆฌ๋
- Python
Archives
- Today
- Total
๐ฑ → ๐ณ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฉ๋ฆฌ๋ฐ๊ธฐ - Python ๋ณธ๋ฌธ
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/12914
ํ๋ก๊ทธ๋๋จธ์ค
์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์ ๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์ ๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.
programmers.co.kr
์ฝ๋
์๊ฐ์ด๊ณผ ๋ฐ์
from itertools import combinations
def solution(n):
answer = 1
b = 1
if n % 2 == 0 :
while n > 2*b:
answer += len(list(combinations(range(n-b), b)))
b += 1
answer += 1
else:
while n >= 2*b:
answer += len(list(combinations(range(n-b), b)))
b += 1
if n < 2*b: break
return answer
์ฌ๊ท๋ฅผ ์ด์ฉํ ํ์ด (ํผ๋ณด๋์น)
import sys
sys.setrecursionlimit(10**7)
memo=[1,1]
def solution(n):
if len(memo)-1>=n:
return memo[n]
else:
memo.append(solution(n-1)+solution(n-2))
return memo[n]%1234567
ํผ๋ณด๋์น
def solution(n):
a, b = 1, 2
for i in range(2,n):
a, b = b, a+b
return b
๋ฌธ์ ๋ณด๋ฉด ์กฐํฉ๋ฐ์ ์๊ฐ์๋๋๋ฐ ํผ๋ณด๋์น๋ ์ด๋ป๊ฒ ์๊ฐํด๋ด์ ๊ฑฐ์ง
..
๊ฐ๊ธธ์ด ๋ฉ๋ค ๋ฉ์ด ..!>!>
728x90
'Algorithms' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ ์ฐพ๊ธฐ - python (0) | 2023.08.25 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ทค ๊ณ ๋ฅด๊ธฐ - Python (0) | 2023.08.15 |
[ํ๋ก๊ทธ๋๋จธ์ค] N๊ฐ์ ์ต์๊ณต๋ฐฐ์ - Python (0) | 2023.08.13 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ฒด์ก๋ณต - python (0) | 2023.08.02 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ ๋งต๊ฒ - python (0) | 2023.08.02 |