Blue Bridge Cup Python Group - Snake Filling
Topic description
This question is a fill-in-the-blank question. After calculating the result, use the output statement in the code to output the filled result. As shown in the figure below, Xiao Ming fills an infinitely large matrix with a "snake" of positive integers starting from 1.
It is easy to see that the number in the second row and second column of the matrix is 5. Can you count the number in the 20th row and 20th column of the matrix?
Running limit
Maximum running time: 1s
Maximum running memory: 128M
'''
对角线上的元素为1,5,13,21
为前一个元素+行号的4倍
'''
res=1
for i in range(1,20):
res += 4*i
print(res)
The answer is 761
Thank you for your support. Your one-click three-connection is the biggest driving force for Ganggang students!