fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Scanner;
  7. import java.lang.Math;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. Scanner in = new Scanner(System.in);
  15. int m1,m2,m3,x;
  16. m1 = in.nextInt();
  17. m2 = in.nextInt();
  18. m3 = in.nextInt();
  19. if ( ( m1 + m2 + m3 ) % 3 == 0 )
  20. {
  21. if ( m1 != m2 && m1 != m3 && m2 != m3 )
  22. {
  23. System.out.print(Math.max ( Math.max ( m1 , m2 ) , m3 ) - ( ( m1 + m2 + m3 ) / 3 ));
  24. }
  25. else if ( m1 == m2 )
  26. {
  27. x = ( m3 - ( m1 + m2 + m3 ) / 3 );
  28. if ( x < 0 )
  29. {
  30. System.out.print(-x);
  31. }
  32. else System.out.print(x);
  33. }
  34. else if ( m1 == m3 ) {
  35. x = ( m2 - ( m1 + m2 + m3 ) / 3 );
  36. if ( x < 0 )
  37. {
  38. System.out.print(-x);
  39. }
  40. else System.out.print(x);
  41. }
  42. else if ( m2 == m3 ) {
  43. x = ( m1 - ( m1 + m2 + m3 ) / 3 );
  44. if ( x < 0 )
  45. {
  46. System.out.print(-x);
  47. }
  48. else System.out.print(x);
  49. }
  50. }
  51. else System.out.print("IMPOSSIBLE");
  52. }
  53. }
Success #stdin #stdout 0.06s 2184192KB
stdin
1 2 4
stdout
IMPOSSIBLE