python,时间复杂度优化

好想上华东师大呀 edited 2 年,9 月前

代码无误,如何降低该python代码的时间复杂度

n = int(input())
nums = [0]*n
for i in range(n):
    nums[i]=int(input())

for i in range(n):
    flag = nums[i]
    m = 1
    while(flag > m):
        flag -= m
        m += 1
    if flag == 1:
        print(1)
    else:
        print(0)

Comments