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
- dfs
- dict
- python
- level3
- 프로그래머스
- 백준
- 재귀
- DP
- level1
- 가상메모리 관리
- MYSQL
- 다이나믹 프로그래밍
- BFS
- 딕셔너리
- 그리디
- 코딩테스트
- 힙
- 파이썬
- level0
- N과M
- 가상메모리
- 구현
- 다익스트라
- 수학
- 스택
- 운영체제
- 브루트포스
- level2
- BOJ
- programmers
Archives
- Today
- Total
동캄의 코딩도장
백준 9009 [피보나치] 파이썬 본문
https://www.acmicpc.net/problem/9009
#백준 9009
import sys
dp=[0]*(101)
dp[0]=0
dp[1]=1
dp[2]=1
dp[3]=2
for i in range(3,51):
dp[i]=dp[i-1]+dp[i-2]
n=int(sys.stdin.readline())
for i in range(n):
ans=[]
k=int(sys.stdin.readline())
for j in range(50,0,-1):
if k>=dp[j]:
k-=dp[j]
ans.append(dp[j])
if k==0:
break
ans.sort()
for a in ans:
print(a,end=' ')
print()
dp와 그리디를 섞은 문제이다.
'코테 > BOJ' 카테고리의 다른 글
백준 4796 [캠핑] 파이썬 (0) | 2022.09.05 |
---|---|
백준 1105 [팔] 파이썬 (0) | 2022.09.05 |
백준 11497 [통나무 건너뛰기] 파이썬 (0) | 2022.09.05 |
백준 20413 [MVP 다이아몬드 (Easy)] 파이썬 (0) | 2022.09.05 |
백준 14400 [편의점 2] 파이썬 (0) | 2022.09.05 |