Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sve;
- import java.util.Arrays;
- import java.util.Scanner;
- public class Playground {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int count = Integer.parseInt(scan.nextLine());
- int[] numbers = Arrays.stream(scan.nextLine().split("\\s+"))
- .mapToInt(Integer::parseInt)
- .toArray();
- boolean found = false;
- if (numbers.length < 4) {
- System.out.println("No");
- return;
- }
- for (int i = 0; i < numbers.length; i++) {
- int first = numbers[i];
- for (int j = 0; j < numbers.length; j++) {
- int second = numbers[j];
- if (second == first) {
- continue;
- }
- for (int k = 0; k < numbers.length; k++) {
- int third = numbers[k];
- if (third == second || third == first) {
- continue;
- }
- for (int l = 0; l < numbers.length; l++) {
- int fourth = numbers[l];
- if (fourth == third || fourth == second || fourth == first) {
- continue;
- }
- String firstPair = first + "" + second;
- String secondPair = third + "" + fourth;
- if (firstPair.equals(secondPair)) {
- System.out.println(first + "|" + second + "==" + third + "|" + fourth);
- found = true;
- }
- }
- }
- }
- }
- if (found == false) {
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment