We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ecccf3b commit 3b2cc10Copy full SHA for 3b2cc10
1 file changed
live10/test103/문제2/백한결.py
@@ -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