fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int b1, b2, b3, pas, need;
  7. bool f;
  8. cin >> b1 >> b2 >> b3;
  9. need = (b1 + b2 + b3)/3;
  10. pas = (abs(b1 - need) + abs(b2 - need) + abs(b3 - need)) / 2;
  11. f = (b1 + b2 + b3) % 3;
  12. (f == 1) and cout << "IMPOSSIBLE";
  13. (f == 0) and cout << pas;
  14. return 0;
  15. }
Success #stdin #stdout 0s 15232KB
stdin
30 9 74
stdout
IMPOSSIBLE