Problem statement is here: http://acm.timus.ru/problem.aspx?space=1&num=2066
This is a tricky problem. Try to come up with three random integers (which may be positive or zero) and try to get the minimum value. You will quickly note that the minimul value follows a pattern 🙂
public void solve(int testNumber, InputReader in, OutputWriter out) { int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int[] nums = new int[]{a, b, c}; Arrays.sort(nums); int max = nums[2] * nums[1] > nums[2] + nums[1] ? nums[2] * nums[1] : nums[2] + nums[1]; out.println(nums[0] - max); }