完整代码:
n = int(input()) def calc(n): temp = 0 for i in range(1, n + 1): temp += i if temp == n: return i elif temp > n: t = temp - n if t % 2 == 0: return i else: i += 1 y = t + i temp += i while y % 2 != 0: i += 1 y = t + i temp += i return i return -1 print(calc(n))