@@ -0,0 +1,1656 @@
+# Importing standard libraries%0Aimport sys%0Aimport fractions%0Afrom math import ceil%0Afrom math import sqrt%0A%0A# Parsing functions %0A'''%0A    Reads in an integer from stream passed in as the parameter. Simple%0A    parsing function that can read from files as well as standard input%0A''' %0Adef parseInt(stream):%0A    return int(stream.readline().rstrip())%0A%0A'''%0A    Generates factors of a particular number by iterating through the num%0A    upto sqrt(num) . Efficient approach using prime factor generation. The%0A    function reduce if new to you, just computes result of the supplied%0A    function f (in this case list.__add__) on the first two elements of the%0A    supplied list, obtains a result and then performs the same function on%0A    the result and the next element in the list. In this way it reduces the %0A    entire list to one result%0A'''%0Adef genFactors(n):    %0A    return set(reduce(list.__add__, %0A                %5B %5Bi, n//i%5D for i in range(1, int(n**0.5) + 1) if n %25 i == 0 %5D ) )%0A'''%0A    Core Function. Checks if a number is both even as well as a perfect %0A    square. Returns true if yes, False other wise via a boolean comparison%0A'''%0Adef isEvenPerfectSquare(n):%0A    return n %25 2 == 0 and ceil(sqrt(n)) == sqrt(n)%0A%0A# Main function for the program%0Aif __name__ == %22__main__%22:%0A    stream = sys.stdin%0A    t = parseInt(stream)%0A    for i in range(t):%0A        n = parseInt(stream)%0A        f = genFactors(n)%0A        f.remove(n)%0A        reqDiv = 0%0A        allDiv = len(f)%0A        for i in f:%0A            if(isEvenPerfectSquare(i)):%0A                reqDiv += 1%0A        %0A        prob = fractions.Fraction(reqDiv,allDiv)%0A        prob = str(prob)%0A        print prob%0A        %0A

Create MehtaAndHisLaziness.py