DILEMMA - DILEMMA

As a part of his maths test, little Max aged five has to find out maximum of two concatenated numbers written on a card. Unfortunately the card was torn by his elder brother into two pieces. Max has to now join the two pieces. If one piece has 78 and the other has 783, he can join them in two ways to get 78783 or 78378. He has to find the maximum number. Can you write a program to help him out?

Input

The first line must have the two numbers. Each of the numbers can have n-digits, 1 <= n <= 30,000. The numbers are separated by a space.

Output

The maximum number of the two formed after concatenation must be printed.

Example

Input:
78 783

Output:
78783
Input:
567 78

Output:
78567

Added by:Vasavi OPC Team
Date:2013-01-21
Time limit:1s-5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYTHON PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET

hide comments
2019-08-04 14:19:53
hint : use string and compare
ac in one go
2018-06-08 03:57:40
42B here.
2013-01-24 12:44:41 (Tjandra Satria Gunawan)(曾毅昆)
mine 64B, too easy for python because python has build in function to solve this...
EDIT: finally got it, now 52B too ;-) thanks, I learned something new about python..

Last edit: 2013-01-22 21:27:16
2013-01-24 12:44:41 Francky
53B of trivial code, to be hidden imho...
EDIT : 52 without the trailing \n, @tjandra, you should have make a double useless cast ;-)

Last edit: 2013-01-22 21:02:05
2013-01-24 12:44:41 Alex Anderson
Test cases are fine, but this problem is too easy. I'd recommend hiding it.

Or making it better, like, you have K numbers, need to concatenate in any order, find max possible. Which is slightly better.
2013-01-24 12:44:41 nani


Last edit: 2014-02-08 03:29:43
2013-01-24 12:44:41 Santiago Palacio
Jmm i believe test cases might be wrong...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.