-
Notifications
You must be signed in to change notification settings - Fork 0
/
1038.cpp
56 lines (48 loc) · 819 Bytes
/
1038.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
bool str_less_than(const string &A, const string &B)
{
if (A.size() < B.size() && A == B.substr(0, A.size()))
{
return A+B < B+A;
}
if (A.size() > B.size() && B == A.substr(0, B.size()))
{
return A+B < B+A;
}
return A < B;
}
vector<string> records;
int main()
{
int N;
string res = "";
cin >> N;
records.resize(N);
for (int i = 0; i != N; ++i)
{
cin >> records[i];
}
sort(records.begin(), records.end(), str_less_than);
for (int i = 0; i != records.size(); ++i)
{
res += records[i];
}
/* res = "" ʱ, µ÷ÓÃres.at(0)»áÒì³£Í˳ö*/
while (0 != res.size() && res.at(0) == '0')
{
res.erase(0,1);
}
if (res == "")
{
cout << 0 << endl;
}
else
{
cout << res << endl;
}
return 0;
}