csansoon

P6.19 P18203 Fermat's last theorem (2)

Nov 8th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     bool found = false;
  6.     int a, b, c, d, x, y, z;
  7.     while (cin >> a >> b >> c >> d) {
  8.         if (a <= b and c <= d) {
  9.             if ((a == 0 or c == 0) and not found) {
  10.                 found = true;
  11.                 z = a + c;
  12.                 x = a;
  13.                 y = c;
  14.             }
  15.         }
  16.     }
  17.     if (found) cout << x << "^3 + " << y << "^3 = " << z << "^3" << endl;
  18.     else cout << "No solution!" << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment