danielvitor23

Balança Equilibrada

Oct 30th, 2020 (edited)
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define eps 1e-9
  5. #define eq(a, b) (abs(a-b) < eps)
  6.  
  7. double v[4], acc, sum;
  8.  
  9. int main() {
  10.     for (int i : {0, 1, 2, 3}) {
  11.         cin >> v[i];
  12.         acc += v[i];
  13.     }
  14.  
  15.     do {
  16.         sum = 0;
  17.         for (int i : {0, 1, 2, 3}) {
  18.             sum += v[i];
  19.             if (eq(acc - sum, sum)) {
  20.                 cout << "YES\n";
  21.                 return 0;
  22.             }
  23.         }
  24.  
  25.     } while (next_permutation(v, v+4)) ;
  26.  
  27.     cout << "NO\n";
  28.  
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment