首先考察y=0的情形,得到字典d。然后思考y=1的情形,发现就是枚举,然后temp = i+j,方案数相乘即可。 为什么只用考虑i+j?而不用考虑什么i-j、-i+j、-i-j?仔细思考y=0的情形,相信聪明的读者们一定会得到答案。
from copy import deepcopy
MOD = 1000000007
d = {0:10,1:9,2:8,3:7,4:6,5:5,6:6,7:5,8:4,9:3,10:2,-1:9,-2:8,-3:7,-4:6,-5:5,-6:6,-7:5,-8:4,-9:3,-10:2}
d1 = deepcopy(d)
x,y = map(int,input().split())
for i in range(y):
tempd = {}
for i in d.keys():
for j in d1.keys():
temp = i+j
if temp in tempd:
tempd[temp] += d[i]*d1[j]
tempd[temp] %= MOD
else:
tempd[temp] = d[i]*d1[j]
d1 = tempd
print(d1.get(x,0)%MOD)