这题的规律是很好找的,难的就是需要用高精度进行计算。

于是我…厚颜无耻地逃避了高精度,用 Python 打了个表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def locate(x):
a = [1, 3]
for i in range(2, x):
a.append(a[-1] + a[-2])
# print(a)
return a[x - 1]

def solve(x):
t = locate(x)
if x % 2 == 1:
return t ** 2
else:
return t ** 2 - 4

n = int(input())
print(solve(n))
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×