Wednesday, May 23, 2018

AE00 - Rectangles : Classical

#The Python 3 solution is as follows:

import math
a=int(input())                               #input the no. of squares
i=1
sum=0                                         #Count the no. of  pairs(m*n)of factors of a
while i<=a:                                 #such that m*n=no.of squares
    n=math.sqrt(i)                        #sqrt is done to rule out n*m case
    j=1
    while j<=n:
        if(i%j==0):                           
            sum+=1
        j+=1 
    i+=1
print(sum)                              #display the no.of pairs=no. of rectangles 


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!