文章

119

粉丝

68

获赞

92

访问

20.0k

头像
奥运排序问题 题解:代码巨大化,各种情况难以统一美化
P1310 浙江大学机试题
发布于2025年2月11日 10:28
阅读数 97

#include <bits/stdc++.h>
using namespace std;

struct medals {
    int golds, all_medals, people;
    medals(int golds, int all_medals, int people) : golds(golds), all_medals(all_medals), people(people) {};
    bool operator==(medals b) {
        return golds == b.golds && all_medals == b.all_medals && people == b.people;
    }
};

bool compare_by_golds(const medals& a, const medals& b) {
    return a.golds > b.golds;
}

bool compare_by_all_medals(const medals& a, const medals& b) {
    return a.all_medals > b.all_medals;
}

bool compare_by_pergolds(const medals& a, const medals& b) {
    return (double)a.golds / a.people > (double)b.golds / b.people;
}

bool compare_by_permedals(const medals& a, const medals& b) {
    return (double)a.all_medals / a.people > (double)b.all_medals / b.people;
}

int main() {
    int n, m;
    while (cin >> n >> m) {
        vector<medals&g...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发