What’s wrong in my code?
Find It - (Number Theory)
Hey @a19JE0093
Yours logic will only work when queries are prime nos and will not work for non prime nos
Here refer to this for precomputation
for(ll i=0;i<n;i++){ cin>>inp; cnt[inp]++; } sum[0] = 0; sum[1] = n; for(ll i=2;i<100001;i++){ for(ll j=i;j<100001;j+=i){ sum[i] += cnt[j]; } }
Now answer to each query is sum[k]
Ya I understood Thanks for clarifying my doubt.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.