풀이는 나중에 작성...
memo = dict()
song = list(map(int, input().split()))
n = song[0]
def solve(n, song):
if n==0:
if song[0] == song[1] == song[2] == 0: return 1
else: return 0
if (song[0], song[1], song[2], n) in memo:
return memo[(song[0], song[1], song[2], n)]
res = 0
for i in range(1, 8):
a=song[0] - (i&1>0)
b=song[1] - (i&2>0)
c=song[2] - (i&4>0)
if a<0 or b<0 or c<0: continue
res+=solve(n-1, [a, b, c])
memo[(song[0], song[1], song[2], n)] = res%1_000_000_007
# print(res, n)
return memo[(song[0], song[1], song[2], n)]
print(solve(n, song[1:]))
https://www.acmicpc.net/source/52542954
조합을 이용한 수학적 풀이