题解 | #牛牛学数列#
牛牛学数列
https://www.nowcoder.com/practice/0b97367cd2184c12a0e02f7c223aee11
n = int(input()) flag = 1 total = 0 for i in range(1, n+1): total += i * flag flag *= -1 print(total)
牛牛学数列
https://www.nowcoder.com/practice/0b97367cd2184c12a0e02f7c223aee11
n = int(input()) flag = 1 total = 0 for i in range(1, n+1): total += i * flag flag *= -1 print(total)
相关推荐