First observe that when n≤2 there is no nontrivial cut, so the global minimum cut is 0.
The graph has N=n−2 vertices, numbered 3,4,…,n.
Simplify
If ∣S∣,∣S∣≥2, then the lower bound for the cut capacity is 2(N−2)=2(n−4) (because every partition where both sides have size at least 2 contains at least two crossing edges, which can be proved by divisibility). When n≥5, we have 2(n−4)≥n−2−⌊n/3⌋ (equality holds only for n=5), so the minimum cut must be a single‑vertex cut. For n=3,4 the conclusion can be verified directly.
Graph definition
The figure shows the divisibility complement graph for n=10. Vertex 3 is marked in red; the edges between it and other vertices are exactly the candidate minimum cut.
Vertices {3,…,n}; if a∣b or b∣a, they are not connected.
Degree formula
deg(k)=N−⌊kn⌋=n−2−⌊kn⌋
(It is not connected to multiples of k.)
Vertex with minimum degree
⌊kn⌋ decreases as k increases ⟹vertex 3 has the smallest degree (for n≥4; when n=4,6 it ties with other vertices but this does not affect the conclusion).
Global minimum cut
As shown in the figure:
After deleting vertex 3, the capacity is:
n−2−⌊3n⌋
This completes the proof of the conclusion.
Code
C++
#include<bits/stdc++.h>using namespace std;
long long n;
int main() {
cin >> n;
if (n <= 2) cout << 0;
else cout << n - 2 - n / 3;
return 0;
}