20210630#(50) 프로그래머스 k번째수
https://programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr def solution(array, commands): answer = [] for i in commands: newarr = array[i[0] - 1:i[1]] newarr.sort() sorted(newarr) answer.append(newarr[i[2] - 1]) return answer
2021. 6. 30.
20210625#(49) 백준 15988 1, 2, 3 더하기 3 (다이나믹 프로그래밍)
https://www.acmicpc.net/problem/15988 15988번: 1, 2, 3 더하기 3 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 1,000,000,009로 나눈 나머지를 출력한다. www.acmicpc.net import sys n=int(sys.stdin.readline()) dp=[0,1,2,4] for i in range(4,1000001): dp.append((dp[i-3]+dp[i-2]+dp[i-1])%1000000009) for i in range(n): testcase=int(input()) print(dp[testcase]) 기존 1,2,3 더하기 문제에서 n의 범위가 늘어나고 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 ..
2021. 6. 25.
20210622#(46) 백준 9095 1, 2, 3 더하기(다이나믹 프로그래밍)
https://www.acmicpc.net/problem/9095 9095번: 1, 2, 3 더하기 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. www.acmicpc.net #1 n=int(input()) dp=[0,1,2,4] for i in range(4,11): dp.append(dp[i-3]+dp[i-2]+dp[i-1]) for i in range(n): testcase=int(input()) print(dp[testcase]) #2 함수이용(이해하기에 좀 더 쉬울수도 있음) num=int(input()) def sol(n): if n==1: return 1 elif n==2: return 2 elif n==3: return 4 else: return sol..
2021. 6. 22.