UVA10905- Children's Game
来源:互联网 发布:庭院流水桌面软件 编辑:程序博客网 时间:2024/05/21 17:16
Description
4thIIUCInter-University Programming Contest, 2005
A
Childrens 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 given N 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 its 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 are N 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 the N 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
题意: 找出最大的组合数
思路: 类string的使用
CODE:
#include<stdio.h>#include<iostream>#include<algorithm>#include<string>using namespace std;bool cmp(string a,string b){ return a+b>b+a;}int main(){ int n; while(~scanf("%d",&n),n) { string ans[55]; for(int i=0;i<n;i++) cin>>ans[i]; sort(ans,ans+n,cmp); for(int i=0;i<n;i++) cout<<ans[i]; cout<<endl; } return 0;}
- uva10905 - Children's Game
- Uva10905 Children's Game
- uva10905-Children's Game
- UVA10905- Children's Game
- UVA10905 - Children's Game
- uva10905 - Children's Game
- uva10905 - Children's Game
- UVA10905 Children's Game
- [排序]Children's Game uva10905
- BNU19323 UVA10905 Children's Game
- Uva10905 Children's Game (C++String的运运用呀...)
- 10905 - Children's Game
- 10905 - Children's Game
- 10905 - Children's Game
- UVaOJ10905 - Children's Game
- 10905 - Children's Game
- uva Children's Game
- Children's Game
- Nan c++ study
- 黄圣依张柏芝小S不足1.6米 实际身高大曝光
- 悲观锁和乐观锁
- eclipse no more handles )
- poi操作excel,复制sheet,复制行,复制单元格 .
- UVA10905- Children's Game
- android 图标适配
- OracleODU
- 何炅谢娜刘诗诗杨幂黄晓明 明星最新片酬曝光
- error C2065: 'IDD_DIALOG1' : undeclared identifier
- jpype,jpython调用jar包中jdk的问题.
- JAR、WAR、EAR的使用和区别
- XML DOM遍历节点树
- NDAP 日志