codeforces-scrape

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

1954C.md (1428B)


      1 Source: https://codeforces.com/problemset/problem/1954/C
      2 
      3 C. Long Multiplication
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are given two integers $x$ and $y$ of the same length, consisting of digits from $1$ to $9$.
     22 
     23 You can perform the following operation any number of times (possibly zero): swap the $i$-th digit in $x$ and the $i$-th digit in $y$.
     24 
     25 For example, if $x=73$ and $y=31$, you can swap the $2$-nd digits and get $x=71$ and $y=33$.
     26 
     27 Your task is to maximize the product of $x$ and $y$ using the aforementioned operation any number of times. If there are multiple answers, print any of them.
     28 
     29 Input
     30 
     31 The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
     32 
     33 The first line of each test case contains a single integer $x$ ($1 \le x \lt 10^{100}$).
     34 
     35 The second line of each test case contains a single integer $y$ ($1 \le y \lt 10^{100}$).
     36 
     37 Additional constraint on input: the integers $x$ and $y$ consist only of digits from $1$ to $9$.
     38 
     39 Output
     40 
     41 For each test case, print two lines — the first line should contain the number $x$ after performing the operations; similarly, the second line should contain the number $y$ after performing the operations. If there are multiple answers, print any of them.
     42 
     43 Example
     44 
     45 Input
     46 
     47 ```
     48 3
     49 
     50 73
     51 
     52 31
     53 
     54 2
     55 
     56 5
     57 
     58 3516
     59 
     60 3982
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 71
     67 33
     68 5
     69 2
     70 3912
     71 3586
     72 ```