毕竟是我用Python过掉的题,好吧我承认是我懒得写高精度,考场上这题就打个表吧。

n = int(raw_input())
a = 1
b = 5
if n==1: print 1
elif n==2: print 5
else:
    while(n>2):
        c = 3*b-a+2
        a = b
        b = c
        n = n-1
    print c