NOIP2017TG D1T1 小凯的疑惑

题目链接

题意:

对于$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;
    
}

猜你喜欢

转载自www.cnblogs.com/Hansue/p/10925263.html