UVA - 10905-Children's Game
来源:互联网 发布:神马搜索排名软件 编辑:程序博客网 时间:2024/06/06 07:47
就是小孩子玩游戏
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;bool cmp(string a,string b){ return (a+b)>(b+a);}int main(){ //freopen("in","r",stdin); int i,n; string a[100]; while(cin>>n&&n) { for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n,cmp); for(i=0;i<n;i++) cout<<a[i]; cout<<endl; } return 0;}
Description
4thIIUCInter-University Programming Contest, 2005
A
Children’s Game
Input: standard input
Output: standard output
Problemsetter: Md. Kamruzzaman
There are lots of number games for children. These games are pretty easy to play but not so easy to make. We will discuss about an interesting game here. Each player will be givenN positive integer. (S)He can make a big integer by appending those integers after one another. Such as if there are 4 integers as 123, 124, 56, 90 then the following integers can be made – 1231245690, 1241235690, 5612312490, 9012312456, 9056124123 etc. In fact 24 such integers can be made. But one thing is sure that 9056124123 is the largest possible integer which can be made.
You may think that it’s very easy to find out the answer but will it be easy for a child who has just got the idea of number?
Input
Each input starts with a positive integer N (≤ 50). In next lines there areN positive integers. Input is terminated by N = 0, which should not be processed.
Output
For each input set, you have to print the largest possible integer which can be made by appending all theN integers.
Sample Input
Output for Sample Input
4
123 124 56 90
5
123 124 56 90 9
5
9 9 9 9 9
0
9056124123
99056124123
99999
- UVa 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905 - Children's Game
- uva 10905 - Children's Game
- UVA 10905 Children's Game
- UVa 10905 - Children's Game
- Uva-10905-Children’s Game
- UVa 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905-Children’s Game
- UVa 10905: Children's Game
- UVA 10905 - Children's Game
- UVA 10905 Children's Game
- UVA 10905 - Children’s Game
- uva 10905 Children's Game
- uva 10905 Children's Game
- webots仿真机器人平台
- TNS-01251: Cannot set trace/log directory under ADR
- dx9 视口变换 和 投影变换
- mina 线程模型配置
- 函数的类型,函数的声明,函数的定义,函数的调用,函数嵌套,函数递归,形参实参
- UVA - 10905-Children's Game
- 进程与线程的一个简单解释
- Linux的管道命令竖线(|)
- 大数卡特兰(模板)
- leetcode:Populating Next Right Pointers in Each Node
- 互联网产品使用心得——余额管理类
- OC基础知识点
- Python浅谈之总结(整理)
- 三阶四阶魔方自动复原程序(Java)