[Timus] 2066 Simple Expression

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};


        int max =
                nums[2] * nums[1] > nums[2] + nums[1] ?
                        nums[2] * nums[1] : nums[2] + nums[1];

        out.println(nums[0] - max);


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.