codeforces-scrape

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

869B.md (1943B)


      1 Source: https://codeforces.com/problemset/problem/869/B
      2 
      3 B. The Eternal Immortality
      4 
      5 time limit per test
      6 
      7 1 second
      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 Even if the world is full of counterfeits, I still regard it as wonderful.
     22 
     23 Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.
     24 
     25 The phoenix has a rather long lifespan, and reincarnates itself once every *a*! years. Here *a*! denotes the factorial of integer *a*, that is, *a*! = 1 × 2 × ... × *a*. Specifically, 0! = 1.
     26 
     27 Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of *b*! years, that is, ![](https://espresso.codeforces.com/fca843bf75b022c7a28d092dbf2df55158a8a546.png). Note that when *b* ≥ *a* this value is always integer.
     28 
     29 As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.
     30 
     31 Input
     32 
     33 The first and only line of input contains two space-separated integers *a* and *b* (0 ≤ *a* ≤ *b* ≤ 1018).
     34 
     35 Output
     36 
     37 Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 2 4
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 2
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 0 10
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 0
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 107 109
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 2
     75 ```
     76 
     77 Note
     78 
     79 In the first example, the last digit of ![](https://espresso.codeforces.com/99c47ca8b182f097e38094d12f0c06ce0b081b76.png) is 2;
     80 
     81 In the second example, the last digit of ![](https://espresso.codeforces.com/9642ef11a23e7c5a3f3c2b1255c1b1b3533802a4.png) is 0;
     82 
     83 In the third example, the last digit of ![](https://espresso.codeforces.com/844938cef52ee264c183246d2a9df05cca94dc60.png) is 2.