Test instructions
The background of the topic is omitted, it is easy to translate the problem into, give N, n the number of ordered pairs (x, y) of the logarithm of the mutual pigment.
Analysis:
Problems can also continue to be transformed.
According to symmetry, we can assume that x<y, when x=y, satisfies only the conditions (1, 1).
Set F (n) as the set s{(x, y) | x<y and X, Y for the number of reciprocal, then the answer is 2f (n) +1
An F (n) expression is:
, where φ (n) is the Euler function
Here are some introduction to Euler's functions
1#include <cstdio>2 3 Const intMAXN =50000;4 5 intPHI[MAXN +Ten], SUM[MAXN +Ten];6 7 voidPhi_table (intN)8 {9phi[1] =0;Ten for(inti =2; I <= MAXN; ++i)if(!phi[i])//description I is prime number One { A for(intj = i; J <= Maxn; J + =i) - { - if(!phi[j]) phi[j] =J; thePHI[J] = phi[j]/I * (i-1); - } - } - } + - intMain () + { A phi_table (MAXN); atsum[1] = phi[1]; - for(inti =2; I <= MAXN; ++i) Sum[i] = sum[i-1] +Phi[i]; - - intN; - while(SCANF ("%d", &n) = =1&& N) printf ("%d\n",2*sum[n]+1); - in return 0; -}code June
UVa 10820 (play table, Euler function) Send a table