目录
牛客WY33 计算糖果
解析代码
牛客WY33 计算糖果
计算糖果_牛客题霸_牛客网
解析代码
#include <iostream>
using namespace std;
bool isTrue(int a)
{if (a <= 30 && a >= -30){return true;}return false;
}
int main()
{int x1, x2, x3, x4;cin >> x1 >> x2 >> x3 >> x4;int a = (x1 + x3) / 2;int b = (x2 + x4) / 2;int c = x4 - b;if (isTrue(a) && isTrue(b) && isTrue(c) &&a - b == x1 && b - c == x2 && a + b == x3 && b + c == x4){cout << a << " " << b << " " << c;}else{cout << "No";}return 0;
}