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.
#!/bin/python3importosimportsys# n = N!# x + y = xy / n# xn + yn = xy# xy - xn - yn + n^2 = n^2# (x-n)(y-n) = n^2# XY = n^2# answer is number of factors of N!^2# Complete the solve function below.defcount(n,p):count=0n_copy=nwhilen_copy>1:count+=n_copy// pn_copy//= preturncountdefsolve(n):pr=1isprime=[True]*(n+1)fornuminrange(2,n+1):ifnotisprime[num]:continuepr=pr*(2*count(n,num)+1)%1000007formultipleinrange(2*num,n+1,num):isprime[multiple]=Falsereturnprif__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')n=int(input())result=solve(n)fptr.write(str(result)+'\n')fptr.close()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equations
You are viewing a single comment's thread. Return to all comments →