-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9184.py
More file actions
35 lines (24 loc) · 926 Bytes
/
Copy path9184.py
File metadata and controls
35 lines (24 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 9184 신나는 함수 실행
d = [[[0 for col in range(21)] for row in range(21)] for depth in range(21)]
while True:
a, b, c = map(int, input().split())
if a == -1 and b == -1 and c == -1:
break
def w(a, b, c):
if a <= 0 or b <= 0 or c <= 0:
return 1
if a > 20 or b > 20 or c > 20:
return w(20, 20, 20)
if a < b < c:
if d[a][b][c] == 0:
d[a][b][c] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c)
return d[a][b][c]
else:
return d[a][b][c]
else:
if d[a][b][c] == 0:
d[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)
return d[a][b][c]
else:
return d[a][b][c]
print("w(" + str(a) + ", " + str(b) + ", " + str(c) + ") = " + str(w(a, b, c)))