time limit per test 1 second

memory limit per test 256 megabytes

input standard input

output standard output

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! 的个位数

题解:

     ①直接弄会炸,但是发现只要遇到各位0就直接输出0了。

     ②根据上述结论,就算没有0,枚举不超过9个数。

#include<stdio.h>
using namespace std;
long long a,b,ans=1;
int main()
{
scanf("%I64d%I64d",&a,&b);
for(long long i=a+1;i<=b;i++)
{
(ans*=(i%10))%=10;
if(!ans)break;
}
printf("%I64d\n",ans);return 0;
}//Paul_Guderian

也许下一回追梦时依旧会破碎,可人生绝不该任困苦摆布并凋零。

就算还有一丝呼吸我也要拼命追寻,只愿灿烂这平凡而不羁的生命。————汪峰《不羁的生命》

【CF Round 439 B. The Eternal Immortality】的更多相关文章

  1. 【CF Round 439 E. The Untended Antiquity】

    time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...

  2. 【CF Round 439 C. The Intriguing Obsession】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. 【CF Round 439 A. The Artful Expedient】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  4. 【Codeforces Round #439 (Div. 2) B】The Eternal Immortality

    [链接] 链接 [题意] 求b!/a!的最后一位数字 [题解] b-a>=20的话 a+1..b之间肯定有因子2和因子5 答案一定是0 否则暴力就好 [错的次数] 在这里输入错的次数 [反思] ...

  5. 【codeforces】【比赛题解】#869 CF Round #439 (Div.2)

    良心赛,虽然我迟了半小时233333. 比赛链接:#869. 呃,CF的比赛都是有背景的……上次是<哈利波特>,这次是<物语>…… [A]巧妙的替换 题意: Karen发现了石 ...

  6. 【CF Round 434 B. Which floor?】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  7. 【CF Round 434 A. k-rounding】

    Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...

  8. 【CF Round 429 B. Godsend】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. 【Codeforces Round #439 (Div. 2) C】The Intriguing Obsession

    [链接] 链接 [题意] 给你3种颜色的点. 每种颜色分别a,b,c个. 现在让你在这些点之间加边. 使得,同种颜色的点之间,要么不连通,要么连通,且最短路至少为3 边是无向边. 让你输出方案数 [题 ...

随机推荐

  1. What is JPA

    What is JPA JPA可以看做是EJB3.0的一部分,但它又不限于EJB 3.0,你可以在Web应用.甚至桌面应用中使用.JPA只是一种Java持久化标准,它意在规范ORM(对象关系映射模型) ...

  2. Linux下配置npm存放路径,解决权限问题

    1.打开cmd命令行,查看当前配置 输入 npm config ls 先看一下当前npm的配置环境,由于我已经修改过,所以可以看到修改后的路径 2.修改路径 这里需要修改两个路径,module路径和c ...

  3. 死锁-Java代码示例

    class MyThread implements Runnable{ private Object o1 = new Object(); private Object o2 = new Object ...

  4. 【转载】Callable、FutureTask中阻塞超时返回的坑点

    本文转载自:http://www.cnblogs.com/starcrm/p/5010863.html 案例1: package com.net.thread.future; import java. ...

  5. 779. K-th Symbol in Grammar

    class Solution { public: int kthGrammar(int N, int K) { return helper(N, K, false); } int helper(int ...

  6. 对文件 I/O,标准 I/O 的缓冲的理解

    1.标准I/O缓冲区 要理解标准I/O,就要先知道文件I/O的业务逻辑. 下面图示为文件I/O 如执行下面的代码: write(fd, buf2, sizeof(buf2)); 图中 buf:就是bu ...

  7. Card Hand Sorting 18中南多校第一场C题

    一.题意 随机给你一堆牌(标准扑克牌),之后让你按照: 第一优先规则:所有相同花色的在一起 第二优先规则:所有相同花色的必须按照升序或者降序排列 问,你最少要拿出多少张牌插入到其他的地方以维持这个状况 ...

  8. 内部类inner class

    1.什么是内部类,为什么要用内部类? 可以将一个类定义在另一个类的定义内部,这就是内部类. 当描述事物时,事物的内部还有事物,该事物用内部类来描述,因为内部事物在使用外部事物的内容. 如: class ...

  9. PJSIP-PJLIB-Socket

    As we all know,most our projects are need to use the socket to programme.Use socket we can connect o ...

  10. jQuery easyuI datagrid 多行编辑

    在easyUI 动态绑定部分数据后,需要有部分列可以修改,研究了一天终于搞定.这是小弟的做法,望各位有好招的大侠指点. 1.添加jQuery 和jQuery easyuI的引用. 2.添加id为tt的 ...