-
알고리즘 & 자료구조 스터디(10조) 8일차알고리즘 2023. 5. 30. 19:28
Q. 1003 피보나치 수
t = int(input()) for _ in range(t): zeroCount = [1, 0, 1] oneCount = [0, 1, 1] n = int(input()) for j in range(3, n + 1): oneCount.append(oneCount[j-1] + oneCount[j-2]) zeroCount.append(zeroCount[j-1] + zeroCount[j-2]) print(zeroCount[n], oneCount[n])
Q. 2609 공약수와 최소공배수
import math n,m = map(int, input().split()) print(math.gcd(n, m)) print(math.lcm(n, m))
Q. 9461 파도반 수
import sys T = int(sys.stdin.readline()) munyeol = [0 for i in range(101)] munyeol[0] = 1 munyeol[1] = 1 munyeol[2] = 1 for i in range(T): num = int(sys.stdin.readline()) for i in range(3, num + 1): munyeol[i] = munyeol[i -2] + munyeol[i - 3] print(munyeol[num - 1])
'알고리즘' 카테고리의 다른 글
[프로그래머스 level.1] 06.19 (1) 2023.06.19 알고리즘 Day-1 (0) 2023.06.16 알고리즘 & 자료구조 스터디(10조) 7일차 (0) 2023.05.29 알고리즘 & 자료구조 스터디(10조) 6일차 (0) 2023.05.27 알고리즘 & 자료구조 스터디(10조) 5일차 (1) 2023.05.26