Find It - (Number Theory)

What’s wrong in my code?

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]

Hey @a19JE0093
Do u have any other doubt in this or shall I close it?

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.