已经知道 x,y,z,不妨令年数为k(k大于等于0) 即要说明(x+k)=z(y+k) 显然(x-yz)是k的倍数,即(x-yz)%k==0这题就做完了,当然由于数据范围,本题需要高精度乘法,作者做了一下弊,用__int128_t类型 官方答案如下:
#include <iostream>
#define int long long
using namespace std;
signed main()
{
int x, y, z;
cin >> x >> y >> z;
if(x%y==0&&x/y==z)
{
cout << "Yes"<< endl;
return 0;
}
__int128_t t = x-y*z;
__int128_t q = z-1;
if(t%q==0&&t>=0)
{
cout << "Yes"<< endl;
}
else
{
cout << "No"<< endl;
}
return 0;
}