Skip to content

Commit ba593ee

Browse files
committed
[BOJ] #9184. 신나는 함수 실행 / 실버2 / 60분 / 성공
1 parent c5280e1 commit ba593ee

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

minjeong/DFSBFS/2024-07-26-[백준]-#13305-주유소.py

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
def w(a, b, c):
5+
if (a, b, c) in memo:
6+
return memo[(a, b, c)]
7+
if a <= 0 or b <= 0 or c <= 0:
8+
memo[(a, b, c)] = 1
9+
return 1
10+
elif a > 20 or b > 20 or c > 20:
11+
memo[(a, b, c)] = w(20, 20, 20)
12+
elif a < b and b < c:
13+
memo[(a, b, c)] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c)
14+
else:
15+
memo[(a, b, c)] = w(a - 1, b, c) + w(a - 1, b - 1, c) + w(a - 1, b, c - 1) - w(a - 1, b - 1, c - 1)
16+
return memo[(a, b, c)]
17+
18+
memo = {}
19+
while True:
20+
a, b, c = map(int, input().split())
21+
if a == -1 and b == -1 and c == -1:
22+
break
23+
print('w(%d, %d, %d) = %d' % (a, b, c, w(a, b, c)))

0 commit comments

Comments
 (0)