Skip to content

Commit 3b2cc10

Browse files
author
hangyeol
committed
103차 2번 문제풀이
1 parent ecccf3b commit 3b2cc10

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def main():
2+
N = int(input())
3+
4+
dp = [float('inf')] * (N + 1)
5+
dp[0] = 0
6+
7+
for i in range(1, N+1):
8+
if i >= 3 and dp[i - 3] != float('inf'):
9+
dp[i] = min(dp[i], dp[i - 3] + 1)
10+
if i >= 5 and dp[i - 5] != float('inf'):
11+
dp[i] = min(dp[i], dp[i - 5] + 1)
12+
13+
if dp[N] == float('inf'):
14+
dp[N] = -1
15+
16+
print(dp[N])
17+
18+
19+
if __name__ == "__main__":
20+
main()

0 commit comments

Comments
 (0)