question = https://hack.codingblocks.com/contests/c/452/815
answer = https://ide.codingblocks.com/#/s/20413
Number of divisors
Your code will give answer 2 even if it should give 1
like the test case
2
1 1
You can look up on this code
https://ide.codingblocks.com/#/s/20740
in this code did you use the sieve and then checked for the divisors
Yess and storing the count of each primes and then calculate the final answer
So, Here is my solution in python using dictionary.
It passed all the test cases.
Number Of Divisors
#Author- Admin_A
def factors(n):
d=dict()
for i in range(2,int(n**0.5)+1):
if (n%i==0):
cnt=0
while(n%i==0):
cnt+=1
n=int(n/i)
d.update({i:cnt})
if (n!=1):
d.update({n:1})
return d
for _ in range (int(input())):
n=int(input())
a=list(map(int,input().split()))
di=dict()
for i in a:
for k,v in factors(i).items():
#print(k,v)
if k in di.keys():
di[k]=di[k]+v
else:
di[k]=v
#print(di)
cnt=1
for k,v in di.items():
cnt*=v+1
print(cnt)