File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
3+ public class Main {
4+ static int [] num = new int [1005 ];
5+
6+ public static void main (String [] args ) {
7+ Scanner in = new Scanner (System .in );
8+ int N = in .nextInt ();
9+ int i ;
10+ int a1 = 0 , a2 = 0 , a3 = 0 , a5 = -1 ;
11+ int a4 = 0 ;
12+ int cout4 = 0 ;
13+ int flag = 1 ;
14+ boolean a22 = false ;
15+ for (i = 0 ; i < N ; i ++) {
16+ num [i ] = in .nextInt ();
17+ if (num [i ] % 5 == 0 && num [i ] % 2 == 0 ) {
18+ a1 += num [i ];
19+ }
20+ if (num [i ] % 5 == 1 ) {
21+ a2 += (num [i ] * flag );
22+ flag = flag * (-1 );
23+ a22 = true ;
24+ }
25+ if (num [i ] % 5 == 2 ) {
26+ a3 ++;
27+ }
28+ if (num [i ] % 5 == 3 ) {
29+ cout4 ++;
30+ a4 += num [i ];
31+ }
32+ if (num [i ] % 5 == 4 ) {
33+ if (a5 < num [i ]) {
34+ a5 = num [i ];
35+ }
36+ }
37+ }
38+ if (a1 != 0 ) {
39+ System .out .print (a1 + " " );
40+ } else {
41+ System .out .print ("N " );
42+ }
43+ if (a22 ) {
44+ System .out .print (a2 + " " );
45+ } else {
46+ System .out .print ("N " );
47+ }
48+ if (a3 != 0 ) {
49+ System .out .print (a3 + " " );
50+ } else {
51+ System .out .print ("N " );
52+ }
53+ if (cout4 != 0 ) {
54+ System .out .printf ("%.1f" , (1.0 * a4 / cout4 ));
55+ System .out .print (" " );
56+ } else {
57+ System .out .print ("N " );
58+ }
59+ if (a5 != -1 ) {
60+ System .out .print (a5 );
61+ } else {
62+ System .out .print ("N" );
63+ }
64+
65+ }
66+ }
You can’t perform that action at this time.
0 commit comments