please tell me how to solve this problem.

thanks in advance.

sqrt decomposition

you prep all ans for d <= sqrt(n)

for d > sqrt(n) you can brute force

The time complexity is N * sqrt(N)

1 Like

please tell me how to solve this problem.

thanks in advance.

sqrt decomposition

you prep all ans for d <= sqrt(n)

for d > sqrt(n) you can brute force

The time complexity is N * sqrt(N)

1 Like