Advertisement
rengetsu

Timus_1349

Aug 6th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. //Timus 1349
  2. #include <cmath>
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n, ch=0;
  8.     cin >> n;
  9.     for(int a=1;a<101;a++)
  10.     {
  11.         for(int b=a+1;b<101;b++)
  12.         {
  13.             for(int c=b+1;c<101;c++)
  14.             {
  15.                 if((pow(a, n) + pow(b, n))==(pow(c, n)))
  16.                 {
  17.                     cout << a << " " << b << " " << c << endl;
  18.                     ch=1;
  19.                 }
  20.                 if(ch==1){break;}
  21.             }
  22.             if(ch==1){break;}
  23.         }
  24.         if(ch==1){break;}
  25.     }
  26.     if(ch==0){cout << "-1";}
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement