XIDIANOJ 1088 AK after the V8

Source: Internet
Author: User

Title Description

A.D. 20XX years x months x days, V8 and his small partners again early AK (all kill), good V8 in order not to hurt the hearts of other Konjac Konjac, even if AK did not leave early, but because the computer was his two great God teammates to play Gobang (team game Three people a computer), V8 can only a person bored in the draft paper Doodle, when V8 because of miss excessive painting down someone's head, frightened V8 immediately wrote three numbers, 3,2,3, at this time, the wit V8 suddenly found: The three numbers to spell up the maximum is 332! And not 233!!!. The boring V8 wrote down two numbers, 97, 98, and V8 found that the maximum was 9897 instead of 9798. Now the boring V8 wrote n numbers, V8 want to know what the maximum value of the N-numbers to spell up.

Input

Multiple sets of data, please process to the end of the file. The first row of each group of data is a number n (1<=n<=10^5), the second row n digit AI (0<=ai<=10^8).

Output

Each set of data is output in one row, indicating the maximum value it has to spell.

--Text

For people who are lazy with the sort function,

This problem is how to output the comparison results, tried C string is not very convenient, or a C + + string is better

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespaceStd;typedefLong LongLL;strings[100001];BOOLcmpstringAstringb) {    stringS1 = a + B,s2 = B +A; return(S1 >s2);}intMain () {intN;  while(SCANF ("%d", &n)! =EOF) {        inti;  for(i=0; i<n;i++) {cin>>S[i]; } sort (S,s+n,cmp);  for(i=0; i<n;i++) {cout<<S[i]; } printf ("\ n"); }    return 0;}

Xidianoj 1088 AK after V8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.