TJU Problem 2955 Solution – Java

CETVRATA,  is a pretty straight forward question… some (like me) might not realize the extreme simplicity of it at first, but once you realize you’re over thinking it it’s a fairly easy programming problem.

While the question tries to make you think about which corners of the rectangle you have and maybe you’re thinking along that direction, the answer lies within the numbers and their order…  My solution to problem 2955 in java is below.

import java.util.Scanner;

public class p2955 {

    public static void main(String[] args){
        Scanner src = new Scanner(System.in);
        int a = src.nextInt(); // Left
        int b = src.nextInt(); // Right
        int c = src.nextInt(); // Left
        int d = src.nextInt(); // Right
        int e = src.nextInt(); // Left
        int f = src.nextInt(); // Right
        int answer1, answer2 = 0;
        if(a == c)
            answer1 = e;
        else if (a == e)
            answer1 = c;
        else
            answer1 = a;
        if(b == d)
            answer2 = f;
        else if(b == f)
            answer2 = d;
        else
            answer2 = b;
        System.out.printf("%d %dn", answer1, answer2);
    }
}

									

Leave a Reply

Your email address will not be published. Required fields are marked *