以 1 -2 3 4为例,分别创建4个变量存a,b,c,d的值,可以推导以下关系
然后判断两个B的值是否相等,相等则存在满足的整数
代码如下
#include <iostream>
#include <vector>
using namespace std;
int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
int A = (a+c) / 2;
int B1 = (a-c) / -2;
int B2 = (b + d) / 2;
int C = (b-d) / -2;
if (B1 != B2)
cout << "No" << endl;
else
cout << A << " " << B1 << " " << C << endl;
return 0;
}