Children's Game UVA - 10905
看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的更多相关文章
- uva 10905 Children's Game (排序)
题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...
- UVA 10905 Children's Game 孩子的游戏 贪心
题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...
- 【字符串排序,技巧!】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 ...
- UVA 10905 Children's Game (贪心)
Children's Game Problem Description There are lots of number games for children. These games are pre ...
- UVa 10905 - Children's Game 排序,题目没有说输入是int 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 10905 - Children's Game(求多个正整数排列后,所得的新的数字的极值)
4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: st ...
- UVa 10905 Children's Game
注意!这不是单纯的字典序排序,比如90.9,应该是990最大 对字符串排序蛋疼了好久,因为别人说string很慢,所以一直没有用过. 看别人用string还是比较方便的,学习一下 对了,这里的cmp函 ...
- UVA 10905 Children's Game (贪心)
贪心,假如任意给出一个序列,如果两两交换了以后会变大,那么就交换,直到不能交换为止. #include<bits/stdc++.h> using namespace std; ; stri ...
- UVa 10905 孩子们的游戏
https://vjudge.net/problem/UVA-10905 题意: 给定n个正整数,把它们连接成一个最大的整数. 思路: 实在是没想到直接用string来排序了. #include< ...
随机推荐
- 装了as之后提示NO JVM installation found.....
如图. 解决:在AS安装目录下,找到对应的程序[jdk是多少位就打开多少位的]
- Selenium Webdriver wait for JavaScript JQuery and Angular
Hi all, during the last two weeks I was dealing with the best solution to wait for both JQuery, Angu ...
- freeswitch刷新网关方法汇总
1.freeswitch xml配置文件新增网关后,使其生效,可以重启freeswitch或者使用命令方式 fs_cli -H 127.0.0.1 -P 8021 -p hmzj -x sofia p ...
- Cannot add foreign key constraint @ManyToMany @OneToMany
最近在使用shiro做权限管理模块时,使用的时user(用户)-role(角色)-resource(资源)模式,其中user-role 是多对多,role-resource 也是多对多.但是在使用sp ...
- Bootstrap3基础 img-rounded 图片的四个角改成圆角
内容 参数 OS Windows 10 x64 browser Firefox 65.0.2 framework Bootstrap 3.3.7 editor ...
- bzoj4008: [HNOI2015]亚瑟王 dp
题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=4008 思路 神仙啊 \(f[i][j]表示第i个点有j次机会(不管成功与否)\) \(f ...
- 卸载linux系统上自带的mysql
步骤: 1.打开centos命令提示符,切换为root用户 2.输入rpm -qa|grep -i mysql命令以检查系统含有的mysql插件,回车,若没有则说明无自带mysql,系统很干净.若有显 ...
- 深度学习课程笔记(十)Q-learning (Continuous Action)
深度学习课程笔记(十)Q-learning (Continuous Action) 2018-07-10 22:40:28 reference:https://www.youtube.com/watc ...
- Linux命令3——c
cal:calender,显示月历 -j:用凯撒历(dates of julius caesar)的形式来显示月历,不分月份.1-365/366 -m:显示月历时,把星期一定为一周的开始.默认星期日为 ...
- Linux 下上手 STC89C52RC
第一次接触单片机,自然选择了简单的51单片机.然而我的操作系统是 Linux .在 Windows 下上手51似乎很容易.但是 Linux 上搭建 51 开发环境不是很顺. 那么谈谈 Linux 我如 ...