Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<utility>
  4. #include<set>
  5. #include<map>
  6. #include<iostream>
  7. #include<vector>
  8. #include<cmath>
  9. #include<algorithm>
  10. #include<iomanip>
  11. #include<stack>
  12.  
  13. using namespace std;
  14.  
  15. int main() {
  16.     long long n;
  17.     cin >> n;
  18.  
  19.     for (long long a = 0; a * a <= n; a++) {
  20.         for (long long b = 0; b * b <= n; b++) {
  21.             for (long long c = 0; c * c <= n; c++) {
  22.                 for (long long d = 0; d * d <= n; d++) {
  23.                     long long temp = a * a + b * b + c * c + d * d;
  24.                     if (temp == n) {
  25.                         if (a != 0) {
  26.                             cout << a << " ";
  27.                         }
  28.                         if (b != 0) {
  29.                             cout << b << " ";
  30.                         }
  31.                         if (c != 0) {
  32.                             cout << c << " ";
  33.                         }
  34.                         if (d != 0) {
  35.                             cout << d << " ";
  36.                         }
  37.                         //system("pause");
  38.                         return 0;
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.     }
  44.  
  45.     //system("pause");
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement