NOIP2017TG D1T1 Oscar doubts

Topic Link

 

Meaning of the questions:

For $ ax + by \ not = c $, where $ a, b, x, y \ in Z $, $ a, b $ is a constant, seeking $ c_ {max} $ (guaranteed present).

 

Thinking:

When $ x, y> 0 $, easy to get $ c_ {max} = a * b $, when the $ x, y> = 0 $ when there is $ c_ {max} = a * bab $.

Data $ a, b <= 1e9 $, involving multiplication, will burst int $ $, $ long long $ then use type.

 

Code:

#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;
    
}

 

Guess you like

Origin www.cnblogs.com/Hansue/p/10925263.html