标签:模拟,数学

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;
} 

Codeforces869B The Eternal Immortality相关推荐

  1. CodeForces - 869B The Eternal Immortality

    题意:已知a,b,求的最后一位. 分析: 1.若b-a>=5,则尾数一定为0,因为连续5个数的尾数要么同时包括一个5和一个偶数,要么包括一个0. 2.若b-a<5,直接暴力求即可. #in ...

  2. 【CodeForces - 869】 A B C E 【组合数打表】

    A The Artful Expedient Rock- Paper! After Karen have found the deterministic winning (losing?) strat ...

  3. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  4. 4、Eternal框架-持有者

    2019独角兽企业重金招聘Python工程师标准>>> 持有者Container.java持有,所有的控制器和拦截器实例,多个拦截器构成拦截器链. 初始化控制器:非常简单,在Disp ...

  5. 3、Eternal框架-控制器

    2019独角兽企业重金招聘Python工程师标准>>> 介绍 MVC:Model-View-Controller,包括三类对象,Model模型对象.View视图表示.Controll ...

  6. 2、Eternal框架-svn_有更新!

    2019独角兽企业重金招聘Python工程师标准>>> 我在code.google.com上建立了eternal项目. 下载地址为:http://code.google.com/p/ ...

  7. 26、Eternal框架v2-框架设计 前置分发器 1、代码

    2019独角兽企业重金招聘Python工程师标准>>> package cn.eternal.web;import cn.eternal.web.core.Dispatcher; i ...

  8. 永恒之蓝(Eternal Blue)复现

    永恒之蓝介绍 什么是永恒之蓝 永恒之蓝(Eternal Blue)爆发于2017年4月14日晚,是一种利用Windows系统的SMB协议漏洞来获取系统的最高权限,以此来控制被入侵的计算机.甚至于201 ...

  9. IDEA2020版导入tomcat的jar包到eternal libraries时遇到的问题

    在写web项目时,需要导入tomcat的jar包,之前一直是手动在tomcat安装目录下的lib文件手动复制需要的jar包到项目中web-inf文件下粘贴.每次都需要粘贴很麻烦, 而eternal l ...

最新文章

  1. Outlook2010 Bug 一则
  2. mysql5.7单机多实例_Mysql 5.7.21单机多实例安装
  3. .net错误处理机制
  4. 【五线谱】变音记号 ( 升号 # | 降号 b | 重升号 x | 重降号 bb )
  5. 为什么选择Java?Java具体好在哪?
  6. mpvue小程序架构搭建详细介绍
  7. oracle安装前准备,Oracle 安装前准备
  8. mysql mysqldump触发器备份_MySQL常用的备份工具之mysqldump
  9. 数据结构和算法详解(三)——递归、排序、散列表
  10. 12个强大的Web服务测试工具
  11. NOI2018退役记
  12. 联想7x04服务器装系统,联想硬盘保护EDU7X的安装方法.doc
  13. 8分钟教你学会局域网邮箱服务器搭建
  14. html特效文本框,各种html文本框input特效
  15. linux网络使用情况分析工具
  16. python的彪悍特性--自省
  17. 蓝牙电话/耳机和蓝牙音乐profile
  18. SAP ABAP 销售订单创建BAPI 正常订单/借贷项订单/退货订单
  19. windows 平台使用dul 抽取Linux oracle ASM 磁盘数据文件
  20. html5代码好学吗,0基础能学习Html5吗?Html5好学吗?

热门文章

  1. 如何在mac下制作微信表情
  2. Python 爬虫、抓包
  3. matlab中制作软件,在matlab app designer中制作多个3d图形动画
  4. 模型加速之轻量化网络
  5. POJ 3693 Maximum repetition substring (后缀数组)
  6. 每天3个面试题精研 - 前端 - 第4-6天
  7. 电子信息工程考研:12大专业方向解读
  8. 第三方直播美颜SDK的美颜功能是怎么实现的?
  9. 人工智能第八章答案神经网络,神经网络简答题
  10. MapServer 之 发布网络地图服务(WMS-Web Map Service)