|
|
вернуться в форум1073 - square country Hello i wrote the following code in python , but it takes too much time, hwo should it be improved class timus1073: def __init__(self): pass def problem(self,y): a = [0] + range(1,60001) b = [x**2 for x in range(1,246)] for i in b: j = 0 while j+i <= 60000: if (a[j+i] > a[j] + 1): a[j+i] = a[j] + 1 j = j + 1 return a[y] if __name__ == "__main__": p = timus1073() a = input() print p.problem(int(a)) |
|
|