题意:
对于$ax+by\not= c$,其中$a,b,x,y\in Z$,$a,b$为常数,求$c_{max}$(保证存在)。
思考:
当$x,y>0$时,易得$c_{max}=a*b$,则当$x,y>=0$时,有$c_{max}=a*b-a-b$。
数据中$a,b<=1e9$,涉及乘法,会爆$int$,于是用$long long$型。
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long LL; LL a,b; int main(){ scanf("%lld%lld",&a,&b); printf("%lld",a*b-a-b); return 0; }