#pragma warning(disable:4996);
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a1, a2, a3,a5;
double a4;
int main()
{
int n;
int f1, f2, f3, f4, f5;
f1 = f2 = f3 = f4 = f5 = 0;//用来标识是否有该分类存在
int temp = 1;//第二类交错求和使用
while (scanf("%d", &n) != EOF)
{
for (int i = 0;i < n;i++)
{
int x;
cin >> x;
if (x % 5 == 0 && x % 2 == 0)
{
f1 = 1;
a1 += x;
}
if (x % 5 == 1)
{
f2 = 1;
a2 += x * temp;
temp *= -1;
}
if (x % 5 == 2)
{
f3 = 1;
a3++;
}
if (x % 5 == 3) {
f4++;
a4 += x;
}
if (x % 5 == 4)
{
f5 = 1;
if (a5 < x)
{
a5 = x;
}
}
}
if (f1 != 0) printf("%d ", a1);
else printf("N ");
if (f2 != 0) printf("%d ", a2);
else printf("N ");
if (f3 != 0) printf("%d ", a3);
else printf("N ");
if (f4 != 0) printf("%.1lf ", a4/f4*1.0);
else printf("N ");
if (f5 != 0) printf("%d\n", a5);
else printf("N\n");
}
return 0;
}
问题 G: 数字分类 (20)
最新推荐文章于 2021-08-17 06:48:03 发布