senb1

krsu 661 (60 points)

Mar 3rd, 2023
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. /*
  2. by: senb1
  3. */
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. #define ll long long
  8. #define ull unsigned long long
  9. #define all(x) x.begin(), x.end()
  10. #define fr first
  11. #define sc second
  12. #define mk make_pair
  13. #define rall(x) x.rbegin(), x.rend()
  14. #define endl '\n'
  15.  
  16. using namespace std;
  17.  
  18. const ll mod = 998244353;
  19. const ll maxn = 1e6 + 5;
  20. const ll inf = 1e9 + 6;
  21.  
  22. void solve() {
  23.     int m, o, a, b;
  24.     cin >> m >> o >> a >> b;
  25.  
  26.     for (int x = 0; x <= m; x++) {
  27.         for (int y = 0; y <= m; y++) {
  28.             for (int z = 0; z <= m; z++) {
  29.                 if (x * x + y * y + z * z == o) {
  30.                     if ((x - m) * (x - m) + y * y + z * z == a) {
  31.                         if (x * x + (y - m) * (y - m) + z * z == b) {
  32.                             cout << x << ' ' << y << ' ' << z << endl;
  33.                             return;
  34.                         }
  35.                     }
  36.                 }
  37.                 if (x * x + y * y + z * z > o) {
  38.                     break;
  39.                 }
  40.             }
  41.             if (x * x + y * y > o) {
  42.                 break;
  43.             }
  44.         }
  45.     }
  46. }
  47. /*
  48.  
  49. */
  50.  
  51. int main() {
  52.     ios::sync_with_stdio(0);
  53.     cin.tie(0);
  54.  
  55.     int t = 1;
  56.     // cin >> t;
  57.     while (t--)
  58.         solve();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment