import java.util.*;
import java.text.DecimalFormat;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, count = 0;
int N = sc.nextInt();
boolean isMinus = true;//判断加减交替
boolean isNotExist = true;//判断这个数是否存在
for(int i=0; i<N; i++){
int num = sc.nextInt();
if(num%5==0 && num%2 == 0){
A1+=num;
}
if(num %5 == 1){
if(isMinus){
A2 += num;//第一个是加,0+第一个数
}else{
A2 -= num;
}
isMinus = !isMinus;
isNotExist = false;
}
if(num %5 ==2){
A3++;
}
if(num %5 ==3){
A4 += num;
count++;
}
if(num%5 == 4 && num>A5){
A5 = num;
}
}
String str = (A1 == 0) ? "N " : A1+" ";
str += (isNotExist) ? "N " : A2+" ";
str += (A3 == 0) ? "N " : A3+" ";
str += (A4 == 0) ? "N " : new DecimalFormat("0.0").format(A4*1.0/count) + " ";
str += (A5 == 0) ? "N" : A5 + "";
System.out.println(str);
}
}
|
题意
|
例子解析
|
A1
|
个位为0的数相加
|
30=10+20
|
A2
|
个位为1或者6的数,按顺序求和
|
11=1-6+16
|
A3
|
个位为2或者7的数的个数
|
2-> 2,7
|
A4
|
个位为3或者8的数,相加求平均数,
精确到小数点后1位
|
9.7!=13+3+8+18????
|
A5
|
个位为4或者9的数里最大的数
|
9
|