看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. oracle数据库的一个表中,怎么设置字段的默认值

    如果表已经存在,用如下方法设置默认值. alter table 表名 modify 字段名 default 默认值; 如test表中设置address字段为'浙江省',可用如下语句: alter ta ...

  2. Python3 tkinter基础 LabelFrame Radiobutton 形成两组不相互限制的单选按钮

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

  3. shell编程(四)之循环控制语句(for,while,until,break,continue,case)

    for循环 语法:for NAME in LIST; do 循环体 done 列表生成方式:1.整数列表 {start...end} $(seq,[start [step]] end)2.glob / ...

  4. tp框架中的一些疑点知识-3

    rewrite就是伪静态, 伪静态就是 rewirte, 可以把入口地址隐藏掉. 兼容模式就是 普通模式 和 pathinfo模式的 结合, 前面是普通模式 ?s= , 后面的 模块/控制器/操作和参 ...

  5. (转)Spring Cloud(一)

    (二期)22.微服务框架spring cloud(一) [课程22]spirng c...简介.xmind54KB [课程22]spirng cl...架构.xmind0.5MB [课程22]负载均. ...

  6. oracle 之 插入超长字段并包含&字符的处理方法

    oracle 在插入超长数据字符串时是默认转为varchar2类型,而这类型只有4000字节,即使通过oracle改变字符串类型为clob,也是在插入时默认转为varchar2类型. 处理方式:可以通 ...

  7. P2536 [AHOI2005]病毒检测

    反思 对于*符号,明明可以让相同位置再次匹配下一个,或者跳过当前位置匹配,但是却写了个把trie的子树全部push进队列的垃圾写法,结果一直MLE 告辞 思路 模板串多且不长,可以塞到trie树里,这 ...

  8. LOJ 534 花团(线段树+dfs栈)

    题意 https://loj.ac/problem/534 思路 又是复杂度错误的一题,\(O(n^2\log n)\) 能过 \(15000\) . 虽然看起来强制在线,其实是一道假的在线题.首先按 ...

  9. 【Hadoop 分布式部署 七: 使用ntp配置内网中集群机器时间同步 】

    集群的时间要同步,如果时间不同步,会出现很多问题. 找一台机器做时间服务器 所有的机器与这台机器的时间进行定时的同步 比如,每日十分钟同步一次 我们这里使用  hadoop-senior.zuoyan ...

  10. Angular CLI命令

    ng 基础命令 npm install –g @angular/cli npm install -g @angular/cli@latest ng serve –prot –aot 启动项目并压缩项目 ...