十分经典的一道数学题,证明题。
证明方法比较繁琐,具体证明可以看这个博客
公式可以当作一个定理来记:x y 互质,则ax + by不能表示的最大数为 x * y - x - y
import java.io.*;
class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(System.out);
static int a, b;
public static void main(String []args) throws IOException{
String []s = br.readLine().split(" ");
a = Integer.parseInt(s[0]);
b = Integer.parseInt(s[1]);
pw.println(a * b - a - b);
pw.flush();
pw.close();
br.close();
}
}