题目链接:https://vjudge.net/problem/CodeForces-869B
因为 a ≤ b所以我们只要求b * (b-1) * (b-2) … *(a+1)的个位数即可(如果a刚好和b相等结果就是1), 当然这样还不够,我们会发现一个数的阶乘足够大,则在进行若干次计算后它的个位数必定会等于0 ,又因为0乘任何数都是0,所以如果遇见0我们直接break就好了
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define mst(a) memset(a, 0, sizeof(a))
#define _test printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
const ll ll_INF = 233333333333333;
const int maxn = 1e3 + 10;
int main(void)
{
ll a, b, fac=1;
cin >> a >> b;
for (ll i = b; i>a; i--)
{
fac = fac * i % 10;
if (!fac)
break;
}
cout << fac << endl;
return 0;
}