|
|
вернуться в форум3-rd test time limit exceded, but why? Python 3.8 Послано Dmitry 13 авг 2022 10:11 I have two solutions! Time: 1.15 solution: numbers = [] for i in range(int(input())): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' number = int((n * 2) ** 0.5) y = (number * (number - 1)) // 2 y2 = y + number y += 1 if n <= y2: print_s += '1' if n == y else '0' else: print_s += '1' if n == y + number else '0' print(print_s) Time: 1.15 solution: numbers = [] for i in range(int(input())): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' length = 1 while n > length: n -= length length += 1 print_s += '1' if n == 1 else '0' print(print_s) Help me pls!! Edited by author 13.08.2022 10:14 Re: 3-rd test time limit exceded, but why? Python 3.8 n=int(input()) numbers=[] for i in range(0,n): numbers.append(int(input())) print_s = '' for n in numbers: if len(print_s) > 0: print_s += ' ' length = 1 while n > length: n -= length length += 1 print_s += '1' if n == 1 else '0' print(print_s) |
|
|