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

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.

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.

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, . Note that when b ≥ a this value is always integer.

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.

Input

The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).

Output

Output one line containing a single decimal digit — 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和b求b的阶乘除以a的阶乘的商的末尾数字。

  显然,当a和b的差大于等于10的时候结果为0.

  当a和b的差小于10的时候,暴力计算就好了(当然,不是把a!和b!)。

Code

 /**
* Codeforces
* Problem#869B
* Accepted
* Time: 30ms
* Memory: 0k
*/
#include <bits/stdc++.h>
#ifndef WIN32
#define Auto "%lld"
#else
#define Auto "%I64d"
#endif
using namespace std; long long a, b; inline void init() {
scanf(Auto""Auto, &a, &b);
} inline void solve() {
if(b - a > ) puts("");
else {
int res = ;
for(int i = b % , c = ; c < b - a; c++, i = (i + ) % ) {
res = (res * i) % ;
}
printf("%d\n", res);
}
} int main() {
init();
solve();
return ;
}

Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)的更多相关文章

  1. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  2. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii ...

  3. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  4. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  5. Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

  6. Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation

    还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n ...

  7. Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort

    Problem - B - Codeforces 就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数 结果只需输出是否可以整成升序的 思路: 需要奇数偶数 ...

  8. Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】

    题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...

  9. Codeforces Round #754 (Div. 2), problem: (A) A.M. Deviation泪目 万万没想到狂wa是因为这

    Problem - A - Codeforces 题目 题意很简单每次操作可以使得a1 a2  a3任意两个数分别+1  -1 求最后使得a+c-2b绝对值的最小值 BUG就是最后忽略了-2和2这一点 ...

随机推荐

  1. cocos2d-x C++ iOS工程集成第三方支付宝支付功能

      一.在支付宝开放平台下载支付宝SDK(https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.WWgVz8&tr ...

  2. hive javaapi 002

    默认开启10000端口开启前,编辑hive-site.xml设置impersonation,防止hdfs权限问题,这样hive server会以提交用户的身份去执行语句,如果设置为false,则会以起 ...

  3. html5-select和datalist元素

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  4. BestCoder Round #55 ($)

    C 构造一个矩阵,然后采用矩阵快速幂 #include <iostream> #include <algorithm> #include <string.h> #i ...

  5. sitecore系列教程之更改您的个人设置

    在Sitecore控制面板中,您可以设置个人设置,例如密码或区域和语言选项,以使应用程序满足您的需求. 要更改您的个人设置: 在Sitecore Launchpad上,单击“ 控制面板”. 在“控制面 ...

  6. 线程&进程

    扯淡的yuan 并发&并行 并发:是指系统具有处理多个任务(动作)的能力. 并行:是指系统具有 同时 处理多个任务(动作)的能力. 同步&异步 同步:当进程执行到一个IO(等待外部数据 ...

  7. [NOIP2005普及组]采药(01背包)

    题目描述 描述 辰辰是个很有潜能.天资聪颖的孩子,他的梦想是称为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到个到处都是草药的山洞里对他说 ...

  8. rabbitmq和redis用作消息队列的区别

    将redis发布订阅模式用做消息队列和rabbitmq的区别: 可靠性redis :没有相应的机制保证消息的可靠消费,如果发布者发布一条消息,而没有对应的订阅者的话,这条消息将丢失,不会存在内存中:r ...

  9. 如何删除自己上传的CSDN资源(亲测有效)

    今天发现有一个资源上传错了,想重新上传,删掉以前的资源,才发现CSDN并没有提供删除资源的功能,然后去网上搜了下,这才删除了,不知道怎么删除的小伙伴看过来~ 1.首先,找到自己想要删除资源的页面,举个 ...

  10. 13年总结js,css,java xml

    --------------------------------------javaScript知识点----------------------------- jQuery对象[Object obj ...