Suppose the C-June is (0, 0), then the upper right is (n-1, n-1).
The premise that a point (x, y) can be seen is gcd (x, y) = 1, so answer =∑phi (i) * 2 + 2-1 =∑phi (i) * 2 + 1 (1 <= i < n). +2 is because (1, 0), (0, 1) two points, 1 is because (1, 1) repeated calculations
-------------------------------------------------------------------------
#include <bits/stdc++.h>using namespace std;const int MAXN = 40009;int PHI[MAXN], n; void Phis () {for (int i = 1; i < n; i++) phi[i] = i;for (int i = 2; i < n; i++) if (phi[i] = = i)For (int j = i; J < n; j + = i)Phi[j] = phi[j]/I * (i-1);}int main () {int ans = 0;cin >> N;phis ();for (int i = 1; i < n; i++) ans + = phi[i];cout << ans * 2 + 1 << "\ n";return 0;}
------------------------------------------------------------------------
2190: [SDOI2008] Honor Guard Time Limit:Ten Sec Memory Limit:259 MB
Submit:1716 Solved:1087
[Submit] [Status] [Discuss] Description
As a sports Commissioner, C June is responsible for the training of the honor guard. Guard of Honor is composed of students of N * N of the square, in order to ensure that the procession uniform, c June will follow the guard of Honor's left rear, according to the number of students in the line of sight to determine whether the team is neat (such as). Now, C-June wants you to tell him the number of students you can see when the team is neat.
Input
A total of a number n.
Output
A total of a number, that is, c June should see the number of students.
Sample Input 4
Sample Output 9
HINT
"Data size and conventions" for 100% of data, 1≤n≤40000
Source
Arithmetical
Bzoj 2190: [SDOI2008] Honor guard (Euler function)