https://www.acmicpc.net/problem/1463import sysinput = sys.stdin.readlineprintf = printdp = [0] * 1000001dp[0] = 0dp[1] = 0dp[2] = 1dp[3] = 1for i in range(4, 1000001): dp[i] = dp[i - 1] + 1 if(i % 3 == 0): dp[i] = min(dp[i], dp[i // 3] + 1) if(i % 2 == 0): dp[i] = min(dp[i], dp[i // 2] + 1) target = int(input())printf(dp[target])
https://www.acmicpc.net/problem/9461아니 문제 설명에서 점화식을 바로 세울 수 있는 문제가 있다고?import sysinput = sys.stdin.readlineprintf = printtestCase = int(input())dp = [0] * 102dp[0] = 1dp[1] = 1dp[2] = 1for i in range(3, 101): dp[i] = dp[i - 2] + dp[i - 3]for i in range(testCase): target = int(input()) printf(dp[target - 1])