codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

508B.md (1865B)


      1 Source: https://codeforces.com/problemset/problem/508/B
      2 
      3 B. Anton and currency you all know
      4 
      5 time limit per test
      6 
      7 0.5 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.
     22 
     23 Reliable sources have informed the financier Anton of some information about the exchange rate of currency you all know against the burle for tomorrow. Now Anton knows that tomorrow the exchange rate will be an even number, which can be obtained from the present rate by swapping exactly two distinct digits in it. Of all the possible values that meet these conditions, the exchange rate for tomorrow will be the maximum possible. It is guaranteed that today the exchange rate is an odd positive integer *n*. Help Anton to determine the exchange rate of currency you all know for tomorrow!
     24 
     25 Input
     26 
     27 The first line contains an odd positive integer *n* — the exchange rate of currency you all know for today. The length of number *n*'s representation is within range from 2 to 105, inclusive. The representation of *n* doesn't contain any leading zeroes.
     28 
     29 Output
     30 
     31 If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1.
     32 
     33 Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from today's exchange rate by swapping exactly two digits. Exchange rate representation should not contain leading zeroes.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 527
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 572
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 4573
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 3574
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 1357997531
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 -1
     71 ```