0
点赞
收藏
分享

微信扫一扫

P1012 拼数


题目描述

设有nn个正整数(n≤20)(n≤20),将它们联接成一排,组成一个最大的多位整数。

例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213

又如:n=4时,4个整数7,13,44,246联接成的最大整数为:7424613

输入格式

第一行,一个正整数n。

第二行,n个正整数。

输出格式

一个正整数,表示最大的整数

输入输出样例

输入 #1

3
13 312 343

输出 #1

34331213

Code

/*
^....0
^ .1 ^1^
.. 01
1.^ 1.0
^ 1 ^ ^0.1
1 ^ ^..^
0. ^ 0^
.0 1 .^
.1 ^0 .........001^
.1 1. .111100....01^
00 11^ ^1. .1^
1.^ ^0 0^
.^ ^0..1
.1 1..^
1 .0 ^ ^
00. ^^0.^
^ 0 ^^110.^
0 0 ^ ^^^10.01
^^ 10 1 1 ^^^1110.1
01 10 1.1 ^^^1111110
010 01 ^^ ^^^1111^1.^ ^^^
10 10^ 0^ 1 ^^111^^^0.1^ 1....^
11 0 ^^11^^^ 0.. ....1^ ^ ^
1. 0^ ^11^^^ ^ 1 111^ ^ 0.
10 00 11 ^^^^^ 1 0 1.
0^ ^0 ^0 ^^^^ 0 0.
0^ 1.0 .^ ^^^^ 1 1 .0
^.^ ^^ 0^ ^1 ^^^^ 0. ^.1
1 ^ 11 1. ^^^ ^ ^ ..^
^..^ ^1 ^.^ ^^^ .0 ^.0
0..^ ^0 01 ^^^ .. 0..^
1 .. .1 ^.^ ^^^ 1 ^ ^0001
^ 1. 00 0. ^^^ ^.0 ^.1
. 0^. ^.^ ^.^ ^^^ ..0.0
1 .^^. .^ 1001 ^^ ^^^ . 1^
. ^ ^. 11 0. 1 ^ ^^ 0.
0 ^. 0 ^0 1 ^^^ 0.
0.^ 1. 0^ 0 .1 ^^^ ..
.1 1. 00 . .1 ^^^ ..
1 1. ^. 0 .^ ^^ ..
0. 1. .^ . 0 .
.1 1. 01 . . ^ 0
^.^ 00 ^0 1. ^ 1 1
.0 00 . ^^^^^^ .
.^ 00 01 ..
1. 00 10 1 ^
^.1 00 ^. ^^^ .1
.. 00 .1 1..01 ..
1.1 00 1. ..^ 10
^ 1^ 00 ^.1 0 1 1
.1 00 00 ^ 1 ^
. 00 ^.^ 10^ ^^
1.1 00 00 10^
..^ 1. ^. 1.
0 1 ^. 00 00 .^
^ ^. ^ 1 00 ^0000^ ^ 01
1 0 ^. 00.0^ ^00000 1.00.1 11
. 1 0 1^^0.01 ^^^ 01
.^ ^ 1 1^^ ^.^
1 1 0.
.. 1 ^
1 1
^ ^ .0
1 ^ 1
.. 1.1 ^0.0
^ 0 1..01^^100000..0^
1 1 ^ 1 ^^1111^ ^^
0 ^ ^ 1 1000^
.1 ^.^ . 00
.. 1.1 0. 0
1. . 1. .^
1. 1 1. ^0
^ . ^.1 00 01
^.0 001. .^
*/
// train —— 1012.cpp created by VB_KoKing on 2019-08-14.
/* Procedural objectives:

Variables required by the program:

Procedural thinking:

Functions required by the program:

Determination algorithm:

Determining data structure:


*/
/* My dear Max said:
"I like you,
So the first bunch of sunshine I saw in the morning is you,
The first gentle breeze that passed through my ear is you,
The first star I see is also you.
The world I see is all your shadow."

FIGHTING FOR OUR FUTURE!!!
*/

#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

void solve();

using namespace std;

int main(){
solve();
return 0;
}

bool cmp(const string a, const string b) {
return a + b > b + a;
}

void solve() {
int n;
string num[27];

scanf("%d",&n);
for (int i = 0; i < n; i++)
cin >> num[i];

sort(num, num + n, cmp);

for (int i = 0; i < n; i++)
cout << num[i];
cout << endl;
}



举报

相关推荐

0 条评论