看90,956这样的串,在比较完之前,就确定大小的,必定选大的放在前。而x=98,y=980;这样的,比较x+y和y+x的大小。如果x+y更小,y就放前。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=; void init()
{ } void work()
{ } bool cmp(string x,string y)
{
for(int i=;i<x.size()&&i<y.size();++i)
{
if(x[i]<y[i])return ;
else if(x[i]>y[i])return ;
}
string s1=x+y,s2=y+x;
return s1<s2;
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//cout<<casenum<<endl;
//for(lon time=1;time<=casenum;++time)
int n;
for(int time=;cin>>n,n;++time)
{
vector<string> vct(n);
for(int i=;i<n;++i)
{
cin>>vct[i];
}
sort(vct.begin(),vct.end(),cmp);
for(int i=vct.size()-;i>=;--i)cout<<vct[i];
cout<<endl;
}
return ;
}

Children's Game UVA - 10905的更多相关文章

  1. uva 10905 Children's Game (排序)

    题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...

  2. UVA 10905 Children's Game 孩子的游戏 贪心

    题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...

  3. 【字符串排序,技巧!】UVa 10905 - Children’s Game

    There are lots of number games for children. These games are pretty easy to play but not so easy to ...

  4. UVA 10905 Children's Game (贪心)

    Children's Game Problem Description There are lots of number games for children. These games are pre ...

  5. UVa 10905 - Children's Game 排序,题目没有说输入是int 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. UVa 10905 - Children's Game(求多个正整数排列后,所得的新的数字的极值)

    4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: st ...

  7. UVa 10905 Children's Game

    注意!这不是单纯的字典序排序,比如90.9,应该是990最大 对字符串排序蛋疼了好久,因为别人说string很慢,所以一直没有用过. 看别人用string还是比较方便的,学习一下 对了,这里的cmp函 ...

  8. UVA 10905 Children's Game (贪心)

    贪心,假如任意给出一个序列,如果两两交换了以后会变大,那么就交换,直到不能交换为止. #include<bits/stdc++.h> using namespace std; ; stri ...

  9. UVa 10905 孩子们的游戏

    https://vjudge.net/problem/UVA-10905 题意: 给定n个正整数,把它们连接成一个最大的整数. 思路: 实在是没想到直接用string来排序了. #include< ...

随机推荐

  1. Python3基础 list range+for 等差数列

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Restful framework【第二篇】APIView

    安装djangorestframework 方式一:pip3 install djangorestframework 方式二:pycharm图形化界面安装 方式三:pycharm命令行下安装(装在当前 ...

  3. cygwin下如何运行crontab定时脚本?

    1. 安装cron服务(如果不能启动,使用管理员身份运行cygwin) cygrunsrv -I cron -p /usr/sbin/cron -a -D -I 是安装 cron是服务名 -p /us ...

  4. 最最简单的c语言函数汇编分析

    0x01 环境 xp+vc6.0 0x02 代码 int plus(int x, int y) { return 0; } 以下是vc6.0的反汇编窗口 1: int plus(int x, int ...

  5. (zhuan) 一些RL的文献(及笔记)

    一些RL的文献(及笔记) copy from: https://zhuanlan.zhihu.com/p/25770890  Introductions Introduction to reinfor ...

  6. Docker6之Network containers

    how to network your containers. Launch a container on the default network Docker includes support fo ...

  7. WijmoJS 全面支持 Angular 7

    概述 首先恭喜Angular团队发布Angular 7.0.0版本! 对于大多数开发人员,只需要执行一个命令就可以更新到Angular 7: ng update \@angular/cli \@ang ...

  8. js为什么返回两个对象字符串 objcet objcet ?

    js中两个使用 toString() 对有个有对象的数组进行操作时,为什么返回两个对象字符串 objcet objcet ? [{}].toString(); 返回 "[object Obj ...

  9. SpringBoot war包部署到Tomcat服务器

    (1)pom.xml文件修改<packaging>war</packaging>,默认是jar包,<build>节点中增加<finalName>spri ...

  10. linux golang

    wget -c http://www.golangtc.com/static/go/go1.3.linux-386.tar.gz #下载32位Linux的够源码包 tar -zxvf go1.1.li ...