Make complaints
Sure enough, people are wondering this question, for it is my kind of math slag slag too unfriendly, and where the conclusions want, guess or guess.
A thought
Pure mathematics, seen quickly cut off, have not seen it ...
The conclusion is: known $ a, b $ is a positive integer greater than $ 1 $ coprime, the so indefinite equation $ A X + B Y = C $ not nonnegative integer Solutions maximum integer $ C = A B - A - b $
What seems to be called赛瓦维斯特theorems, but in addition to the solution to a problem of solving the problem, I do not have to search anywhere else, associated with mathematical signs not at all, amazing, is it a mere $ OIer $ before the study formula ?
Prove it.
First, the proband $ A X + B Y = A B - A - B (A, B>. 1, (A, B) =. 1) $ nonnegative integer solution exists.
By contradiction, assuming the presence of $ x> = 0, y> = 0 $, so $ A X + B Y = A B - A - B (A, B>. 1, (A, B) =. 1) $ established.
Transposition to give $ a * (x + 1) + b * (y + 1) = a * b $
$a*(x+1)=b*(a-y-1)$
And because $ (a, b) = 1 $
Then $ b | (x + 1) $
Same reason: $ a | (y + 1) $
And because $ x> = 0, y> = 0 $
Therefore, $ x> = b, y> = a $
则$a*(x+1)+b*(y+1)>=ab+ba>=2ab$
Because $ a> 1, b> 1 $
So $ ab> 1 $
So $ 2ab> ab $
Previously assumed $ a * (x + 1) + b * (y + 1) = a * b $ contradiction, so the assumption is not valid.
Next, to prove $ A X + B Y = C (A, B>. 1, (A, B) =. 1) $, for all $ C> ab-ab $, equations are non-negative integers Solutions
设$C=ka+m-a-b(k>=b,a<=m<=a-1)$,即$ax+by=ka+m-a-b(k>=b,1<=m<=a-1)$
Because $ (a, b) = 1 $, according to the theorem of Shu Pei, found the presence of $ x_0 , y_0∈Z $, so $ ax_0 + by_0 = 1 $
There x_0 $ , $ y_0∈Z, so $ ax_0 + by_0 = m $
$ Y_0 = (m-ax_0) / b $, for different $ m% b $, there are $ b-1 $ $ x_0 $ kind of value, such $ $ integer y_0
We made $ - (b-1) <= x_0 <= - 1 $, in order to guarantee the first $ y_0> = 0 $
Because $ -ax_0> 1, m> = 1 $, so in fact $ y_0> = 1 $
Then take $ y = y_0-1 $, the $ y> = 0 $
则$x_0=(m-by_0)/a$,
$x=(ka+m-a-b-by)/a=k-1+(m-b-by)/a=k-1+(m-b-b(y0-1))/a=k-1+(m-by_0)/a=k-1+x_0$
And because $ - (b-1) <= x_0 <= - 1 $, the $ - (b-1) + k-1 <= x <= - 1 + k-1 $, $ - b + k <= x <= k-2 $
And because $ k> = b $, the $ -b + k> = 0 $, the $ x> = 0 $
Proved.
Ideas two
Violence hit the table to find the law, but under no circumstances OEIS I usually not to be found ...
That depends on luck
Code
To be honest, this question can not paste the code qwq
1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<cstring> 5 #include<queue> 6 #include<algorithm> 7 #include<vector> 8 using namespace std; 9 #define N 255 10 #define ll long long 11 #define INF 0x3f3f3f3f 12 ll a,b; 13 int main() 14 { 15 scanf("%lld %lld",&a,&b); 16 printf("%lld\n",a*b-a-b); 17 return 0; 18 }