Guard of honor this topic
Theoretically
Euler need to use the function
But if this title was changed to a rectangular square
Euler function it is not easy to use
When the GCD abscissa and ordinate of a point will be blocked is greater than 1
So we can determine the number of horizontal and vertical (not greatest common divisor) is the number i of Convention coordinates
f[i] = (n / i) * (m / i)f[i]=(n/i)∗(m/i)
Since some point be counted twice, we're going to look at weight
minus
The complexity is then O (nlogn) of
#include<iostream> #include<cstdio> using namespace std; int py[10000002]; int main() { freopen("matrix.in","r",stdin); freopen("matrix.out","w",stdout); int n,m; ios_base::sync_with_stdio(false); cin>>n>>m; if(n==1&&m == cout) {1<<0; return 0; } if(n==1||m==1) { cout<<1; return 0; } int ans=(n-1)*(m-1); n--;m--; int l=min(n,m); for(int i=l;i>=2;i--) { py[i]=(n/i)*(m/i); for(int j=2* i; j <= l; j + = i) py [i] - = py [j]; years - = py [i]; } Cout << years + 2 ; }
Cattleya number:
So that h (0) = 1, h (1) = 1, catalan a number satisfying the recurrence formula:
h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (n>=2)
Two recursive formula:
H (n-) = H (. 1-n-) * (. 4-* n-2) / (n-+. 1);
Through 项公 formula:
h(n)=(2n!)/n!*(n+1)!