# 题目

A1 = 能被5整除的数字中所有偶数的和；

A2 = 将被5除后余1的数字按给出顺序进行交错求和，即计算n1-n2+n3-n4...；

A3 = 被5除后余2的数字的个数；

A4 = 被5除后余3的数字的平均数，精确到小数点后1位；

A5 = 被5除后余4的数字中最大数字。

13 1 2 3 4 5 6 7 8 9 10 20 16 18

30 11 2 9.7 9

8 1 2 4 5 6 7 9 16

N 11 2 N 9

# 解析

Java有一组没有过，因为时限只有100ms，实在是太难为Java了

# 代码

## C++解法

```#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

const double eps = 1e-12;
int sgn(const double &x) {
if (fabs(x) < eps)
return 0;
return x > 0 ? 1 : -1;
}
int double_round(double num) { return sgn(num) > 0 ? num + 0.5 : num - 0.5; }

int main() {
cin.tie(0);
cin.sync_with_stdio(false);

int n;
cin >> n;
int A[5] = {0, 0, 0, 0, -90000};
bool has[5] = {0, 0, 0, 0, 0};
int flag = 1;
int cnt = 0;
for (int i = 0; i < n; ++i) {
int a, b;
cin >> a;
b = a % 5;

if (b == 0 && a % 2 == 0) {
has[0] = 1;
A[0] += a;
}
if (b == 1) {
has[1] = 1;
A[1] += flag * a;
flag *= -1;
}
if (b == 2) {
has[2] = 1;
A[2]++;
}
if (b == 3) {
has[3] = 1;

A[3] += a;
cnt++;
}
if (b == 4) {
has[4] = 1;
A[4] = A[4] > a ? A[4] : a;
}
}
bool isFirst = true;
for (int i = 0; i < 5; ++i) {
if (isFirst) {
isFirst = false;
} else {
cout << " ";
}
if (has[i])
if (i == 3)
cout << fixed << setprecision(1)
<< (double)double_round((double)A[3] / cnt * 10) / 10;
else
cout << A[i];
else
cout << "N";
}
cout << endl;
return 0;
}
```

## Python解法

```read = [int(i) for i in input().split(" ")]
n = read[0]
del read[0]

calc = [[], [], [], [], []]
for i in read:
calc[i % 5].append(i)

ans = []
calc[0] = [i for i in calc[0] if i % 2 == 0]
calc[1] = [i * (-((idx % 2) * 2 - 1)) for (idx, i) in enumerate(calc[1])]

ans.append(str(sum(calc[0])) if len(calc[0]) > 0 else "N")
ans.append(str(sum(calc[1])) if len(calc[1]) > 0 else "N")
ans.append(str(len(calc[2])) if len(calc[2]) > 0 else "N")
ans.append(str(round(sum(calc[3]) / len(calc[3])*10)/10) if len(calc[3]) > 0 else "N")
ans.append(str(max(calc[4])) if len(calc[4]) > 0 else "N")

print(" ".join(ans))

```

## Java解法

```import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
public static void main(String[] args) throws Exception {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String[] read = input.readLine().split(" ");
int n = Integer.valueOf(read[0]);

boolean[] has = { false, false, false, false, false };
int[] A = { 0, 0, 0, 0, -1001 };

int flag = 1;
int cnt = 0;
for (int i = 0; i < n; ++i) {
int a = Integer.valueOf(read[i + 1]);
int b = a % 5;
if (b == 0 && a % 2 == 0) {
has[0] = true;
A[0] += a;
}
if (b == 1) {
has[1] = true;
A[1] += a * flag;
flag *= -1;
}
if (b == 2) {
has[2] = true;
A[2]++;
}
if (b == 3) {
has[3] = true;
A[3] += a;
cnt++;
}
if (b == 4) {
has[4] = true;
A[4] = A[4]> a?A[4]:a;
}
}

for (int i = 0; i < 5; ++i) {
if (i>0)
System.out.print(" ");
if (has[i])
if (i == 3)
System.out.print(Math.round((float) A[3] / cnt * 10) / 10.0);
else
System.out.print(A[i]);
else
System.out.print("N");
}
System.out.print("\n");
}
}
```