Test instructions
UVa 10820
These two questions are the same topic, but the formula is a little different.
Given the whole point of the range (0, 0) to (n, N), you stand at the origin and ask how many points are visible.
For points (x, y), if G = gcd (x, y) > 1, the point must be blocked by a point (x/g, y/g).
So the points of view except (1, 0) and (0, 1) satisfy the cross-ordinate reciprocity.
The final answer is, where +3 corresponds (1, 1) (1, 0) (0, 1) three points
1#include <cstdio>2 3 Const intMAXN = +;4 intPHI[MAXN +Ten];5 6 voidget_table ()7 {8 for(inti =2; I <= MAXN; ++i)if(!Phi[i])9 {Ten for(intj = i; J <= Maxn; J + =i) One { A if(!phi[j]) phi[j] =J; -PHI[J] = phi[j]/I * (i-1); - } the } - } - - intMain () + { -Freopen ("3090in.txt","R", stdin); + A get_table (); at for(inti =1; I <= MAXN; ++i) Phi[i] + = phi[i-1]; - - intT; -scanf"%d", &T); - for(intKase =1; Kase <= T; ++Kase) - { in intN; -scanf"%d", &n); toprintf"%d%d%d\n", Kase, N, phi[n]*2+3); + } - the return 0; *}
code June
POJ 3090 (Euler function) Visible Lattice Points