The topic asks [1,n] There are several numbers that are $m^k (k>1) $ form.
If this is considered, m known K unknown, for each m statistics its k number is $\lfloor log_mn \rfloor$, again, but M too many, completely not feasible.
And K is far less than M, should in turn consider, M unknown k known, for each K statistics its number of M, that is $\lfloor \sqrt[k]n \rfloor$.
Because $n \leqslant 10^{18}$, and $2^{60} > 10^{18}$, the range of K is an integer less than 60.
However, 60 with the capacity to $2^{60}$ or not, and $m^{a \times b}$, known to be $m^a$ and $m^b$ count, so for all the composite within 60 can be removed from the beginning, that is, only consider the prime number within 60.
And there are only 17 prime numbers within 60, so it's OK.
1#include <cstdio>2#include <cstring>3#include <cmath>4 using namespacestd;5 intprime[]={2,3,5,7, One, -, -, +, at, in, to,Panax Notoginseng, A, +, -, -, -, A};6 intMain () {7 Long LongN;8 while(~SCANF ("%lld",&N)) {9 intpn=0;Ten while((1ll<<prime[pn+1]) <=n) + +PN; One Long Longres=0; A for(intI=1; i< (1<<PN); ++i) { - Long Longtmp=1;intCnt=0; - for(intj=0; j<pn; ++j) { the if((I>>J) &1)==0)Continue; -TMP*=PRIME[J]; ++CNT; - } - if(cnt&1) res+= (Long Long) (POW (n,1.0/tmp) +1e-8); + Elseres-= (Long Long) (POW (n,1.0/tmp) +1e-8); - } +printf"%lld\n", res+1); A } at return 0; -}
HDU2204 Eddy's Hobby (repulsion principle)