注意点
- 本题不难,但很繁琐,需要耐心
- count[5]存放个数,ans[5]存放输出结果,ans为answer的缩写,常用它存放结果
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,t;
int count[5]={0};
int ans[5]={0};
scanf("%d",&N);
while(N--){
scanf("%d",&t);
if(t%5==0){//情况1
if(t%2==0){
ans[0]+=t;
count[0]++;
}
}
if(t%5==1){//情况2
if(count[1]%2==0) ans[1]+=t;
else ans[1]-=t;
count[1]++;
}
if(t%5==2){//情况3
count[2]++;
}
if(t%5==3){//情况4
ans[3]+=t;
count[3]++;
}
if(t%5==4){//情况5
if(ans[4]<t) ans[4]=t;
count[4]++;
}
}
if(count[0]==0)printf("N ");
else printf("%d ",ans[0]);
if(count[1]==0)printf("N ");
else printf("%d ",ans[1]);
if(count[2]==0)printf("N ");
else printf("%d ",count[2]);
if(count[3]==0)printf("N ");
else printf("%.1f ",(double)ans[3]/count[3]);
if(count[4]==0)printf("N");
else printf("%d",ans[4]);
return 0;
}