[Swift] 백준 9095 1, 2, 3 더하기
·
📝 코테/BOJ
import Foundation let T = Int(readLine()!)! for _ in 0.. Int { var cache: [Int] = [1, 2, 4] guard n > 2 else { return n } for num in 3...n { cache.append(cache[num - 3] + cache[num - 2] + cache[num - 1]) } return cache[n-1] }