codeforces-scrape

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

86A.md (1509B)


      1 Source: https://codeforces.com/problemset/problem/86/A
      2 
      3 A. Reflection
      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 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 For each positive integer *n* consider the integer ψ(*n*) which is obtained from *n* by replacing every digit *a* in the decimal notation of *n* with the digit (9  -  *a*). We say that ψ(*n*) is the reflection of *n*. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals 0, reflection of 91 equals 8.
     22 
     23 Let us call the weight of the number the product of the number and its reflection. Thus, the weight of the number 10 is equal to 10·89 = 890.
     24 
     25 Your task is to find the maximum weight of the numbers in the given range [*l*, *r*] (boundaries are included).
     26 
     27 Input
     28 
     29 Input contains two space-separated integers *l* and *r* (1 ≤ *l* ≤ *r* ≤ 109) — bounds of the range.
     30 
     31 Output
     32 
     33 Output should contain single integer number: maximum value of the product *n*·ψ(*n*), where *l* ≤ *n* ≤ *r*.
     34 
     35 Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preferred to use cout (also you may use %I64d).
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 3 7
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 20
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 1 1
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 8
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 8 10
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 890
     73 ```
     74 
     75 Note
     76 
     77 In the third sample weight of 8 equals 8·1 = 8, weight of 9 equals 9·0 = 0, weight of 10 equals 890.
     78 
     79 Thus, maximum value of the product is equal to 890.