P3951 小凯的疑惑

题目地址


基本思路:

  • 首先,a*b可被a或b表示出来.
  • 因为a与b互素,所以a*b-a无法被b表示出来(反证法,若a*b-a=b*k,则b*(a-k)=a).
  • 同理,a*b-b无法被a表示出来.
  • 由此可知,a*b-a-b无法被a和b表示出来.

#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld
",a*b-a-b);
	return 0;
}
原文地址:https://www.cnblogs.com/zbsy-wwx/p/11835351.html