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. Servlet学习笔记03——什么是DAO?

    1.案例 (1)添加用户 step1.建表 create table t_user( id int primary key auto_increment, username varchar(50) u ...

  2. django+xadmin在线教育平台(十)

    剩余app model注册 courses注册 新建courses/adminx.py: # encoding: utf-8 __author__ = 'mtianyan' __date__ = '2 ...

  3. day2_作业1(购物车)

    #!/usr/local/bin/python3 # -*- coding:utf-8 -*- balance=input("\033[36;1mPlease input your sala ...

  4. POJ:2377-Bad Cowtractors

    传送门:http://poj.org/problem?id=2377 Bad Cowtractors Time Limit: 1000MS Memory Limit: 65536K Total Sub ...

  5. JS实现禁用滑动条但滑动条不消失的效果

    //方法 //滑动条 // left: 37, up: 38, right: 39, down: 40, // spacebar: 32, pageup: 33, pagedown: 34, end: ...

  6. linux环境下kettle部署(JDK安装配置,kettle安装配置,资源库配置,定时执行job)

    一.部署准备 1.1 java安装(略) 1.2 JDK配置 1.     命令行键入“cd /etc”进入etc目录 2.     命令行键入“vi profile”打开profile文件 3.   ...

  7. 关于Android SDK无法更新的解决办法

    最新摆弄PhoneGap打包,所以需要安卓的环境,配置后,sdk更新实在是在慢了,上网找了一下,可能被强了,所有总结如下办法,最后弄好了,跟大家分享一下 具体步骤:1:打开SDK Manager.ex ...

  8. Android 人脸识别

    Android人脸识别技术,可以参考下面的网站. http://www.faceplusplus.com.cn/ 本项目使用的就是该网站的api. 项目具体使用的技术代码 /** * 用来压缩图片的方 ...

  9. nodejs安装&bower 安装

    1.进入官网下载:https://nodejs.org/en/ 2.直接进行安装,可以将安装路径设置为:D:\nodejs 3.进入node.js command prompt 命令窗口 4.检测是否 ...

  10. Java入门 手把手教你配置环境变量

    很多人觉得配置Java开发的环境变量很麻烦,很容易忘记,时常被它搞得晕头转向.如果出现这样的情况,那么原因只有一个,你不了解为毛需要配置环境变量,不配置环境变量就不能开发了吗? 答案是:NO!,那么下 ...