1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define lli long long int 6 using namespace std; 7 const int MAXN=10000001; 8 void read(int &n) 9 { 10 char c='+';int x=0;bool flag=0; 11 while(c<'0'||c>'9'){c=getchar();if(c=='-')flag=1;} 12 while(c>='0'&&c<='9') 13 x=(x<<1)+(x<<3)+c-48,c=getchar(); 14 flag==1?n=-x:n=x; 15 } 16 int n,m; 17 bool check[MAXN]; 18 int prime[MAXN]; 19 int mu[MAXN]; 20 int tot=0; 21 int main() 22 { 23 cin>>n; 24 mu[1]=1; 25 for(int i=2;i<=n;i++) 26 { 27 if(!check[i]) 28 prime[++tot]=i,mu[i]=-1;// 只有i与它互质 29 for(int j=1;j<=tot;j++) 30 { 31 if(i*prime[j]>n) 32 break; 33 check[i*prime[j]]=1; 34 if(i%prime[j]==0) 35 { 36 mu[i*prime[j]]=0; 37 break; 38 } 39 else 40 mu[i*prime[j]]=-mu[i]; 41 } 42 } 43 printf("%d ",mu[n]); 44 return 0; 45 }