题解 | #肥宅の简单分类#

肥宅の简单分类

https://ac.nowcoder.com/acm/problem/21432

//这题真恶心
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1005;
int a[N], s[5], T, n, flag, f[5];
double sb;

void work() {
    int cnt = 0;
    for (int i = 1; i <= n; i ++) {
        if (a[i] % 5 == 0 && a[i] % 2 == 0)
            s[0] += a[i], f[0] = 1;
        if (a[i] % 5 == 1) {
            if (flag == 0)
                s[1] += a[i], f[1] = 1, flag = 1;
            else 
                s[1] -= a[i], f[1] = 1, flag = 0;
        }
        if (a[i] % 5 == 2)
            s[2] ++, f[2] = 1;
        if (a[i] % 5 == 3)
            s[3] += a[i], f[3] = 1, cnt ++;
        if (a[i] % 5 == 4)
            s[4] = max(s[4], a[i]), f[4] = 1;
    }
    sb = s[3] * 1.0 / cnt;
}

int main() {
    cin >> T;
    while (T --) {
        flag = 0;
        memset(s, 0, sizeof s);
        memset(f, 0, sizeof f);
        s[4] = -0x3f3f3f3f;
        cin >> n;
        for (int i = 1; i <= n; i ++)
            cin >> a[i];
        work();
        for (int i = 0; i <= 2; i ++)
            if (f[i]) cout << s[i] << " ";
            else cout << "N" << " ";
        if (f[3]) printf("%.1lf ", sb);
        else cout << "N" << " ";
        if (f[4]) cout << s[4] << " ";
        else cout << "N" << " ";
        cout << endl;
    }
    return 0;
}
已写的题解集 文章被收录于专栏

将自己知道的一些竞赛知识推广给大家

全部评论
为什么我只能通过50%啊,还有啥特殊的是我没想到的吗,兄弟们,想了一晚上了md
点赞 回复 分享
发布于 2023-11-01 22:05 重庆
肥宅吗?
点赞 回复 分享
发布于 2023-04-02 18:31 广西

相关推荐

头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
真烦好烦真烦:牛友太有实力了
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务