标签:style blog color os io for div sp log
求一个平面内可见的点,其实就是坐标互质即可,很容易看出来或者证明
所以求对应的欧拉函数即可
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int phi[1010]; int n; void calc(int x) { for (int i=2;i<=x;i++) phi[i]=0; phi[1]=1; for (int i=2;i<=x;i++){ if (!phi[i]) for (int j=i;j<=x;j+=i){ if (!phi[j]) phi[j]=j; phi[j]=phi[j]/i*(i-1); } } } int main() { int t,kase=0; scanf("%d",&t); calc(1001); while (t--) { scanf("%d",&n); n; int ans=3; for (int i=2;i<=n;i++){ ans+=2*phi[i]; } //ans+=2*phi[n]; printf("%d %d %d\n",++kase,n,ans); } }
标签:style blog color os io for div sp log
原文地址:http://www.cnblogs.com/kkrisen/p/3961506.html