P3951 Xiaokai's doubts
Idea:
If a<b,
suppose x is the answer:
x = ma + nbx=ma+nbx=m a+n b
Obviously, n>=0, x will definitely be expressed, which does not meet the meaning of
thequestion. Then suppose n=-1, then x=ma-b is
the largest that cannot be expressed. So, is it enough to make m the largest?
Let's discuss it in three situations:
-
m=b, bring it into the original formula:
x = ma − bx=ma-bx=m a−b
得 : x = b a − b 得:x=ba-b Get : x=b a−b
means x = (a − 1) b means x=(a-1)bI.e. x=(a−1 ) b
then n is not greater than 0, which does not meet the meaning of the question -
m>b, suppose m=b+1;
bring back to the original formula: (b+1)ab
ad+ab
(a-1)b+a
bring back ma+nb, you will find that n=a-1, then this It's not a positive number anymore, it doesn't meet the meaning of the question. -
m<b, then the maximum is b-1
brought back to the original formula: (b-1)ab
and then you will find that this is not enough.
So simplify again:
Answer: ab-ab
#include<bits/stdc++.h>
long long a,b;
int main()
{
scanf("%lld%lld",&a,&b);
printf("%lld\n",(a*b-a-b);
return 0;
}