Advertisement
xerpi

fermat P36430

Nov 3rd, 2013
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int a, b, c, d;
  9.     cin >> a >> b >> c >> d;
  10.     bool solucio_trobada = false;
  11.    
  12.     for (int i = a; i <= b and not solucio_trobada ; ++i) {
  13.         for (int j = c; j <= d and not solucio_trobada; ++j) {
  14.             double n = sqrt(i*i + j*j);
  15.             int num = int(n);
  16.             if (n == double(num)) {
  17.                 cout << i << "^2 + " << j << "^2 = "
  18.                      << num << "^2" << endl;
  19.                 solucio_trobada = true;
  20.      
  21.             }
  22.         }
  23.     }
  24.     if (not solucio_trobada) {
  25.         cout << "No solution!" << endl;
  26.     }
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement