HDU2204 Eddy's Hobby (repulsion principle)

Source: Internet
Author: User

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&LT;&LT;PN); ++i) { -             Long Longtmp=1;intCnt=0; -              for(intj=0; j<pn; ++j) { the                 if((I&GT;&GT;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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.