# BZOJ 2440 完全平方数(莫比乌斯反演，容斥原理)

http://www.lydsy.com/JudgeOnline/problem.php?id=2440

 1 #include<algorithm>
2 #include<cstdio>
3 #include<cmath>
4 #include<cstring>
5 #include<iostream>
6 #define N 160000
7 #define ll long long
8 int mark[200005],p[200005],mul[200005];
10     char ch=getchar();int t=0,f=1;
11     while (ch<'0'||ch>'9'){if (ch=='0') f=-1;ch=getchar();}
12     while ('0'<=ch&&ch<='9'){t=t*10+ch-'0';ch=getchar();}
13     return t*f;
14 }
15 void init(){
16     mul[1]=1;
17     for (int i=2;i<=N;i++){
18         if (!mark[i]){
19             p[++p[0]]=i;
20             mul[i]=-1;
21         }
22         for (int j=1;j<=p[0]&&p[j]*i<=N;j++){
23             mark[i*p[j]]=1;
24             if (i%p[j]) mul[i*p[j]]=-mul[i];
25             else{
26                 mul[i*p[j]]=0;
27                 break;
28             }
29         }
30     }
31 }
32 ll cal(ll x){
33     ll sum=0;
34     for (ll i=1;i*i<=x;i++)
35       sum+=x/(i*i)*mul[(int)i];
36     return sum;
37 }
38 int main(){
39     init();
41     while (T--){
51 }