Visible Lattice Points Time Limit:7000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from co…
题意:求一个正方体里面,有多少个顶点可以在(0,0,0)位置直接看到,而不被其它点阻挡.也就是说有多少个(x,y,z)组合,满足gcd(x,y,z)==1或有一个0,另外的两个未知数gcd为1 定义f(t)为gcd(x,y,z)==t或有一个0,另外的两个未知数gcd为t的组合数 定义F(x)为 ∑p(t)   x|t  =  (n/x)* (n/x) * (n/x+3) 那么满足下面的 则 求出f(1)即为答案 代码: #include<bits/stdc++.h> using namesp…
Visible Lattice Points Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible from point Y iff no other lattice point lies on the segmen…
题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=37193   Visible Lattice Points Time Limit: 1368MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Submit Status Description Consider a N*N*N lattice. One corner is at (0,0,0) and…
http://www.spoj.com/problems/VLATTICE/ 明显,当gcd(x,y,z)=k,k!=1时,(x,y,z)被(x/k,y/k,z/k)遮挡,所以这道题要求的是gcd(x,y,z)==1的个数+{(x,y,0)|gcd(x,y)==1}的个数+3{(0,0,1),(0,1,0),(1,0,0)} 现在不去管最后的三个坐标轴上的点, 设f(i)=|{(x,y,0)|gcd(x,y)==i}|*3+|{(x,y,z)|gcd(x,y,z)==i}|,也就是不在坐标轴上且…
这样的点分成三类 1 不含0,要求三个数的最大公约数为1 2 含一个0,两个非零数互质 3 含两个0,这样的数只有三个,可以讨论 针对 1情况 定义f[n]为所有满足三个数最大公约数为n的三元组数量 F[n]为所有满足三个数的最大公约数能被n整除的三元组数量 显然 F[n]=∑n|df[d] 然后由莫比乌斯反演,f[n]=∑n|dμ[d/n]*F[d] 情况三也是一样的 #include<iostream> #include<algorithm> #include<set&g…
SPOJ Problem Set (classical) 7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible…
7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible from point Y iff no other lat…
/** 题目:Visible Lattice Points 链接:https://vjudge.net/contest/178455#problem/A 题意:一个n*n*n大小的三维空间.一侧为(0,0,0)另一侧为(n,n,n): 问从(0,0,0)出发的经过该范围三维空间内整数点坐标的射线有多少条. 思路: 类比二维的:求1<=x<=n,1<=y<=n; gcd(x,y)=1的对数.因为y/x,所以可以反过来. 三维的:求1<=x,y,z<=n; gcd(x,y,…
题目链接 /* http://www.spoj.com/problems/VLATTICE/ 题意:求一个n*n*n的晶体,有多少点可以在(0,0,0)处可以直接看到. 同BZOJ.2301 题目即要求gcd(i,j,k)=1的(i,j,k)数对个数,1<=i,j,k<=n 由于是立体,所以最后再算上平面的点和坐标轴上的三个点就行了 */ #include<cstdio> #include<cctype> #define gc() getchar() typedef l…