题解:P15021 [UOI 2020 II Stage] 方程
P15021 [UOI 2020 II Stage] 方程
solution
枚举一下,总共有 -1 -1 -1。
做完了。
AC code
#include <bits/stdc++.h>
#define debug(a) cerr << (#a) << " = " << (a) << endl;
#define int long long
#define maxn 100010
#define endl '\n'
using namespace std;
int x, y, z, k;
void solve() {
if (x * x * x + y * y + z == k) {
cout << x << " " << y << " " << z << endl;
}
else if (x * x * x + z * z + y == k) {
cout << x << " " << z << " " << y << endl;
}
else if (y * y * y + x * x + z == k) {
cout << y << " " << x << " " << z << endl;
}
else if (y * y * y + z * z + x == k) {
cout << y << " " << z << " " << x << endl;
}
else if (z * z * z + x * x + y == k) {
cout << z << " " << x << " " << y << endl;
}
else if (z * z * z + y * y + x == k) {
cout << z << " " << y << " " << x << endl;
}
else {
cout << "-1 -1 -1" << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t; t = 1;
while (t--) {
cin >> x >> y >> z >> k;
solve();
}
return 0;
}