-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1012.c
62 lines (59 loc) · 1.11 KB
/
1012.c
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
int main()
{
int N;
scanf("%d", &N);
int a[N], i, j = 1, cnt2 = 0, cnt4 = 0;
int A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0;
for(i = 0; i < N; i++){
scanf("%d", &a[i]);
}
for(i = 0; i < N; i++){
if(a[i] % 5 == 0 && a[i] % 2 == 0){
A1 += a[i];
}
if(a[i] % 5 == 1){
A2 = A2 + j * a[i];
j = j * (-1);
++cnt2;
}
if(a[i] % 5 == 2){
++A3;
}
if(a[i] % 5 == 3){
A4 += a[i];
++cnt4;
}
if(a[i] % 5 == 4){
if(A5 < a[i]){
A5 = a[i];
}
}
}
if(A1 == 0){
printf("N ");
}else{
printf("%d ", A1);
}
if(cnt2 == 0){
printf("N ");
}else{
printf("%d ", A2);
}
if(A3 == 0){
printf("N ");
}else{
printf("%d ", A3);
}
if(A4 == 0){
printf("N ");
}else{
printf("%.1f ", (double)(A4) / cnt4);
}
if(A5 == 0){
printf("N");
}else{
printf("%d", A5);
}
return 0;
}