Advertisement
Guest User

491A-2

a guest
Jun 23rd, 2018
1,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int a, b, c, n;
  7.     cin >> a >> b >> c >> n;
  8.  
  9.     int n3 = c;
  10.     for (int n1 = 0; n1 <= n; n1++)
  11.         for (int n2 = 0; n2 <= n; n2++)
  12.             for (int n4 = 1; n4 <= n; n4++)
  13.                 if (n1 + n3 == a && n2 + n3 == b && n1 + n2 + n3 + n4 == n) {
  14.                     cout << n4;
  15.                     return 0;
  16.                 }
  17.  
  18.     cout << -1;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement