Codeforces869B The Eternal Immortality

79 篇文章 0 订阅
45 篇文章 0 订阅

标签:模拟,数学

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 every a! 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 of b! 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 integers a 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 long
using 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;
} 



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值