To change this license header choose License Headers in Project Proper

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
/**
*
* @author alpha-pc
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int curr;
int max2 = 0;
int max5 = 0;
int max10 = 0;
int max = 0;
for (int i = 0; i < N; i++) {
curr = sc.nextInt();
if (curr % 2 != 0 && curr % 5 != 0 && curr > max2) {
max2 = curr;
}else if (curr % 5 != 0 && curr % 2 != 0 && curr > max5) {
max5 = curr;
}else if (curr % 10 != 0 && curr > max10) {
max10 = curr;
}
if (curr > max && curr % 10 != 0 && curr != max10) {
max = curr;
}
}
int R = sc.nextInt();
int res = ((max2 * max5) > (max10 * max)) ? (max2 * max5) : (max10 * max);
System.out.println("Получено чисел: " + N);
System.out.println("Принятое контрольное значение " + R);
System.out.println("Вычисленное контрольное значение " + res);
if(R == res) {
System.out.println("Контроль пройден");
} else System.out.println("Контроль не пройден");
}
}