Advertisement
SergeyPGUTI

5.1.4

Dec 4th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cin>>n;
  14.     double SQRT=sqrt(n);
  15.     for (int i=0;i<=SQRT;i++)
  16.     {
  17.               for (int j=0;j<=SQRT;j++)
  18.         {
  19.                           for (int k=0;k<=SQRT;k++)
  20.                 {
  21.                               for (int m=0;m<=SQRT;m++)
  22.                         {
  23.                             if (m*m+k*k+j*j+i*i==n)
  24.                             {
  25.                                 cout<<i<<" "<<j<<" "<<k<<" "<<m;
  26.                                 return 0;
  27.                             }
  28.                         }
  29.                 }
  30.         }
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement