码迷,mamicode.com
首页 > 其他好文 > 详细

[UVA-11039]Children's Game

时间:2018-11-24 14:35:14      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:解析   game   out   amp   putc   class   mes   代码   its   

解析

微扰法贪心经典题

代码

#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

标签:解析   game   out   amp   putc   class   mes   代码   its   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!