首页 > 其他 > 详细

[UVA-11039]Children's Game

时间:2018-11-24 13:37:28      阅读:144      评论:0      收藏:0      [点我收藏+]

解析

微扰法贪心经典题

代码

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

bool cmp(const string &x, const string &y) {
    return x + y > y + x;
}

int main() {
    int n;
    while (~scanf("%d", &n) && n) {
        string str[55];
        for (int i = 1; i <= n; ++ i) cin >> str[i];
        sort(str + 1, str + n + 1, cmp);
        for (int i = 1; i <= n; ++ i) cout << str[i];
        putchar(10);
    }
}

[UVA-11039]Children's Game

原文:https://www.cnblogs.com/Alessandro/p/10011151.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!