ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1073. Square Country

1073 - square country
Posted by gogreen 22 Apr 2013 22:15
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))