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
- JS
- ๊ทธ๋ฆฌ๋
- ๊ตญ๋น์ง์
- ํฌ๋กค๋ง
- ํ๋ก๊ทธ๋๋จธ์ค
- ๋ชจ๊ฐ์ฝ
- ๊ฐ๋ฐ
- ํ๋ก ํธ์๋
- Til
- CSS
- ์ฝ๋ฉ์ ํ
- KDT
- ์ฝ๋ฉ
- HTML
- ํ์ด์ฌ
- ํ๋ก์ ํธ
- node.js
- mongodb
- ์ฝ๋ฉํ ์คํธ
- react
- javascript
- ๋ฐฑ์ค
- ์๊ณ ๋ฆฌ์ฆ
- heapq
- ๋๋ฆผ์ฝ๋ฉ
- error
- ํ ์ดํ๋ก์ ํธ
- ๋ ธ๋ง๋์ฝ๋
- fe
- Python
Archives
- Today
- Total
๐ฑ → ๐ณ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฉ๋ฆฌ๋ฐ๊ธฐ - Python ๋ณธ๋ฌธ
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/12914
์ฝ๋
์๊ฐ์ด๊ณผ ๋ฐ์
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 |