We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importmathdefnum_square_divisors(n):result=1reduce=ndivisor=2whiledivisor*divisor<=reduce:exponent=0whilereduce%divisor==0:exponent+=1reduce//= divisorresult*=2*exponent+1divisor+=1ifdivisor==2else2ifreduce>1:result*=3returnresultdefmain():importsysinput=sys.stdin.readdata=input().split()tests=int(data[0])results=[]foriinrange(1,tests+1):n=int(data[i])divisors=num_square_divisors(n)half=(divisors+1)// 2results.append(half)forresultinresults:print(result)// What's wrong with my code, It passes 7 testcases only.. and throw Timeout error?? Anyone please helpif__name__=="__main__":main()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #108: Diophantine reciprocals I
You are viewing a single comment's thread. Return to all comments →