# Python code for 2530. Tiling a Grid With Dominoes Problem code: GNY07H
def tiles(n):
a = [1,1,5,11,36,95,281]
if n<7:
return a[n]
else:
i=7
while i!=n+1:
k=a[i-1]+5*a[i-2]+a[i-3]-a[i-4]
a.append(k)
i+=1
return a[n]
h=input
for t in range(h()):
n =h()
print t+1, tiles(n)
def tiles(n):
a = [1,1,5,11,36,95,281]
if n<7:
return a[n]
else:
i=7
while i!=n+1:
k=a[i-1]+5*a[i-2]+a[i-3]-a[i-4]
a.append(k)
i+=1
return a[n]
h=input
for t in range(h()):
n =h()
print t+1, tiles(n)
No comments:
Post a Comment