A math problem nausea - Oscar doubts

Oscar doubts

The second my blog, Aoao wailing! Apart from anything else, the next challenge!

Magic Portal :

Magical thinking:

First saw this question, I really can not start. Violence can only think of enumeration. then. . . ( Painful past ah ) then the no. Hand several data points, it is easy to find the answers are each less than the product of two prime numbers, then the next test a * bab ,. . . So the success of the code is as follows.

Magical solution to a problem

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    cout<<a*b-a-b;
    return 0;
}

 

Explanation

Asked a big brother, he told me that the subject can be converted to: set a, b, c are positive integers, minimum c0 can make any c> c0, ax + by = c equation has a negative integer solution;

Solution out of the minimum value is c0 = ab-ab.

prove

 

 Because a, b coprime. Can be converted to the original equation a (x0 + bt) + b (y0-at) = c, t coefficients, the equation still holds. Consider the range of x, first of all x> = 0, followed if x = 0 Shi, c0 can be infinite. When x = b, a y may be combined with the same c0 infinite. If x> b, b can be removed from a likewise converted to x a, y merged

Plus a number, c0 can also be taken to infinity. Therefore, x is in the range: 0 - b-1. So by = c-ax> ab-ab-ax> = ab-aba (b-1) = - b, so that y> = - 1. So the problem is simplified to demonstrate: c> ab-ab can be, but not c = ab-ab. When c = ab-ab time, ax + by = ab-

ab => ab = a (x + 1) + b (y + 1) because a and b are coprime, a |. (y + 1), b |. (x + 1) so that a <= y + 1, b <= x + 1.

所以ab=a(x+1)+b(y+1)>=ab+a=2ab<=0,

Equation has no solution, contradiction. So c! = Ab-ab. QED!

 

End Sahua! ! !

It is important to learn math

Not open long long ruined his life! ! !

End Sahua! ! !

 

 

Guess you like

Origin www.cnblogs.com/YYCether666/p/11033887.html