Advertisement
artemgf

Очередной пробный тур

Mar 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <set>
  5. #include <map>
  6. #include <algorithm>
  7. #include <string>
  8. #include <math.h>
  9. #include <vector>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     int X, Y, C;
  16.  
  17.     cin >> X >> Y >> C;
  18.  
  19.     if (X + Y < C)
  20.         cout << "Impossible";
  21.     else
  22.         if (X + Y == C)
  23.             cout << X << " " << Y;
  24.         else
  25.             if(X>=C||Y>=C)
  26.             if (X >= C)
  27.             {
  28.                 cout << C << " " << C - C;
  29.             }
  30.             else
  31.                 cout << C - C << " " << C;
  32.             else
  33.             {
  34.                 bool t = false;
  35.                 for (int i = X; i > -1; i--)
  36.                 {
  37.                     for (int j = Y; j > -1; j--)
  38.                     {
  39.                         if (j + i == C)
  40.                         {
  41.                             cout << i << " " << j;
  42.                             t = true;
  43.                             break;
  44.                         }
  45.                     }
  46.                     if (t == true)
  47.                         break;
  48.                 }
  49.             }
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement