Codeforces869B The Eternal Immortality

来源:互联网 发布:程序员为什么容易猝死 编辑:程序博客网 时间:2024/06/05 09:44

标签:模拟,数学

Even if the world is full of counterfeits,I still regard it as wonderful.

Pile up herbs and incense, and arise againfrom the flames and ashes of its predecessor — as is known to many, thephoenix does it like this.

The phoenix has a rather long lifespan, andreincarnates itself once everya! years. Here a! denotes thefactorial of integer a, that is,a! = 1 × 2 × ... × a. Specifically, 0! = 1.

Koyomi doesn't care much about this, butbefore he gets into another mess with oddities, he is interested in the numberof times the phoenix will reincarnate in a timespan ofb! years, thatis, . Note that when b ≥ a this value is always integer.

As the answer can be quite large, it wouldbe enough for Koyomi just to know the last digit of the answer in decimalrepresentation. And you're here to provide Koyomi with this knowledge.

Input

The first and only line of input containstwo space-separated integersa and b (0 ≤ a ≤ b ≤ 1018).

Output

Output one line containing a single decimaldigit — the last digit of the value that interests Koyomi.

Examples

Input

2 4

Output

2

Input

0 10

Output

0

Input

107 109

Output

2

Note

In the first example, the last digit of is 2;

In the second example, the last digit of is 0;

In the third example, the last digit of is 2.

分析:直接模拟a+1->b的乘积即可,注意如果ans已经等于0,那么直接跳出循环输出0

Code

#include<bits/stdc++.h>#define rep(i,a,b) for(long long i=a;i<=b;i++)#define dep(i,a,b) for(long long i=a;i>=b;i--)#define LL unsigned long longusing namespace std;LL a,b,ans=1; int main(){cin>>a>>b;rep(i,a+1,b){ans=(ans*i)%10;if(ans==0)break;}cout<<ans<<endl;return 0;} 


原创粉丝点击