[Two points + content + Mobius Function] BZOJ2440: [Zhongshan 2011] Full square number of mo than black inversion

Source: Internet
Author: User
the

From small to large k of the number of square-free factors. (the original problem expression slightly problematic)
K<=1e+9

This problem has nothing to do with inversion, it uses the Mobius function.
First of all confirm that the two-point answer is then validated, now the problem is transformed to find the number of square-free factors in [1,mid].
How to ask for it. Consider the 1~SQRT (P is the set of mass in the (m))
Multiples of the total number of =[(PI) 2]−[(PI∗PJ) 2 multiples]+[(PI∗PJ∗PK) 2 multiples of]−[(PI∗PJ∗PK∗PT) 2) ... Total number of =[(p_i) ^2 multiples of]-[(p_i*p_j) ^2 multiple]+[(p_i*p_j*p_k) ^2 multiples of]-[(p_i*p_j*p_k*p_t) ^2.
How to sum it. By observing we find that the previous coefficients of the term [x^2 multiples] of any [X2 multiples] are just mu[x].
And then it's perfectly settled,
Number of ANS1 to M non-square factor =∑⌊m√⌋iμ (i) ∗⌊m/i2⌋ans_{1 to M non-square factor number}=\sum_i^{\lfloor \sqrt m \rfloor}\mu (i) *\lfloor M/i^2\rfloor

 #include <cstdio> #include <cmath> #include <cstring> #include <
Algorithm> using namespace std;
typedef long Long LL;
const int maxn=100015, n=100000;
int _TEST,N,M,MU[MAXN],P[MAXN];
LL ans;
BOOL VIS[MAXN];
    void Get_mu () {memset (vis,1,sizeof (VIS));
    Mu[1]=1;
        for (int i=2;i<=n;i++) {if (vis[i]) p[++p[0]]=i, mu[i]=-1;
            for (int j=1;j<=p[0]&&i*p[j]<=n;j++) {vis[i*p[j]]=false;
            if (i%p[j]==0) {mu[i*p[j]]=0; break;}
        Mu[i*p[j]]=-mu[i];
    }} ll get (ll mid) {ll res=0;
    int T=sqrt (mid);
    for (LL i=1;i<=t;i++) res+= (Mid/(i*i)) *mu[i];
return res;
    int main () {freopen ("bzoj2440.in", "R", stdin);
    Freopen ("Bzoj2440.out", "w", stdout);
    Get_mu ();
    scanf ("%d", &_test);
        while (_test--) {scanf ("%d", &m); LL l=m,r=1e+10;
        Ans=1; 
Related Article

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.