思路:
首先,我们要知道大名鼎鼎的塞瓦维斯特定理:
已知 为大于 1 的正整数,且 ( 互为质数),则使不定方程 不存在非负整数解的最大整数为 。
证明:
使用反证法,假设存在 。满足 ,通过变形导出矛盾(如 与 导致组合值必然超过 )。
代码:
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
cin>>n>>m;
cout<<n*m-n-m;
return 0;
}首先,我们要知道大名鼎鼎的塞瓦维斯特定理:
已知 为大于 1 的正整数,且 ( 互为质数),则使不定方程 不存在非负整数解的最大整数为 。
使用反证法,假设存在 。满足 ,通过变形导出矛盾(如 与 导致组合值必然超过 )。
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
cin>>n>>m;
cout<<n*m-n-m;
return 0;
}