标签:define include out style space == name cout points
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=1e7+10; int vis[maxn]; int mu[maxn]; int prime[maxn]; int tot=0; int sum1[maxn]; int sum2[maxn]; void get_mu() { mu[1]=1; vis[1]=1; for(int i=2;i<maxn;i++) { if(!vis[i]) {mu[i]=-1; prime[++tot]=i; } for(int j=1;j<=tot && i*prime[j]<maxn;j++) { vis[i*prime[j]]=1; if(i%prime[j]==0) break; mu[i*prime[j]]=-mu[i]; } } for(int i=1;i<maxn;i++) sum2[i]=sum2[i-1]+mu[i]; } int main() { get_mu(); int T; cin>>T; while(T--) { int n; cin>>n; ll ans=0; for(int l=1,r;l<=n;l=r+1) { r=n/(n/l); ans+=(sum2[r]-sum2[l-1])*1ll*(n/l)*(n/l)*(n/l); ans+=(sum2[r]-sum2[l-1])*1ll*(n/l)*(n/l)*3; } cout<<ans+3<<endl; } }
Visible Lattice Points SPOJ - VLATTICE 三维+莫比乌斯反演
标签:define include out style space == name cout points
原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/10704583.html