From OEIS we know that the number of powerful numbers below N is about $2.1732\sqrt{N}=O(\sqrt{N})$
In fact I do have an algorithm to do so, but some technical issue beats me.
The outline of the algorithm is as follows:
powerful←[1]
primelist←primes below $\sqrt{n}$
for p in primelist:
for powerful_num in powerful:
newpowerful_list←[powerful_num*$p^2$,powerful_num*$p^3$,powerful_num*$p^4$......]
powerful←sorted(powerful+newpowerful_list)//this step costs too much
The marked step aims to keep the order of the powerful number list, but both sorting and binary searching/inserting(which needs to move many numbers in the list) are too time-consuming. This algorithm counts every powerful number only once, for which I think myself on the right track, but due to that step, the algorithm would not be capable for $N>10^{11}$(in fact computing time seems to grow linearly for $N>10^{8}$).
So, how could I optimize my algorithm? Any help is appreciated.
