看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. topcoder srm 662 div1

    problem1 link 首先枚举差值$d$,判断是否存在一个序列任意连续两个之间的差值小于$d$. 首先将数字排序,然后从小到大依次放置每一个数字.每个当前的数字有两个位置可以放,当前序列的前面或 ...

  2. luogu P5105 不强制在线的动态快速排序

    前言 考试的时候居然想错了区间贡献,mdzz 思路 题目看着很方啊,难道要树套树? 但数据范围提醒我们,是nlogn的复杂度 Sort(S)的定义是不是很鬼畜 但我们不动脑子的打表容易发现 连续区间[ ...

  3. IntelliJ IDEA 中SpringBoot对Run/Debug Configurations配置 SpringBoot热部署

    运行一个SpringBoot多模块应用 使用SpringBoot配置启动: Use classpath of module选中要运行的模块 VM options:内部配置参数 -Dserver.por ...

  4. Download and Installation of Kibana

    下载以及安装 https://www.elastic.co/downloads/kibana 1.Download and unzip Kibana 2. Open config/kibana.yml ...

  5. BZOJ5018: [Snoi2017]英雄联盟

    Description 正在上大学的小皮球热爱英雄联盟这款游戏,而且打的很菜,被网友们戏称为「小学生」.现在,小皮球终于受不 了网友们的嘲讽,决定变强了,他变强的方法就是:买皮肤!小皮球只会玩N个英雄 ...

  6. P2153 [SDOI2009]晨跑

    思路 典型的最小费用最大流问题,拆点,每个点对应的入点和出点之间连一条cap=1的边表示只能经过一次的限制条件 然后其他边从u的出点连向v的入点即可 代码 #include <cstdio> ...

  7. (转)ResNet, AlexNet, VGG, Inception: Understanding various architectures of Convolutional Networks

    ResNet, AlexNet, VGG, Inception: Understanding various architectures of Convolutional Networks by KO ...

  8. 生存分析与R--转载

    生存分析与R 生存分析是将事件的结果和出现这一结果所经历的时间结合起来分析的一类统计分析方法.不仅考虑事件是否出现,而且还考虑事件出现的时间长短,因此这类方法也被称为事件时间分析(time-to-ev ...

  9. React Native 炫酷的动画库 实现任何AE动画 lottie-react-native

    lottie-react-native 传送门 1.npm i --save lottie-react-native 2.react-native link lottie-ios 3.react-na ...

  10. 虚拟现实外包公司—北京动点飞扬软件承接VR/AR软件、游戏外包

    欢迎通过以下方式联系北京动点飞扬软件外包业务咨询QQ:372900288 (全天在线)   咨询邮箱:SLteam@vip.qq.com   同时我们还承接 HTML5外包. kinect外包.Uni ...