【CF Round 439 B. The Eternal Immortality】
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】的更多相关文章
- 【CF Round 439 E. The Untended Antiquity】
time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...
- 【CF Round 439 C. The Intriguing Obsession】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 439 A. The Artful Expedient】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【Codeforces Round #439 (Div. 2) B】The Eternal Immortality
[链接] 链接 [题意] 求b!/a!的最后一位数字 [题解] b-a>=20的话 a+1..b之间肯定有因子2和因子5 答案一定是0 否则暴力就好 [错的次数] 在这里输入错的次数 [反思] ...
- 【codeforces】【比赛题解】#869 CF Round #439 (Div.2)
良心赛,虽然我迟了半小时233333. 比赛链接:#869. 呃,CF的比赛都是有背景的……上次是<哈利波特>,这次是<物语>…… [A]巧妙的替换 题意: Karen发现了石 ...
- 【CF Round 434 B. Which floor?】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 434 A. k-rounding】
Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...
- 【CF Round 429 B. Godsend】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【Codeforces Round #439 (Div. 2) C】The Intriguing Obsession
[链接] 链接 [题意] 给你3种颜色的点. 每种颜色分别a,b,c个. 现在让你在这些点之间加边. 使得,同种颜色的点之间,要么不连通,要么连通,且最短路至少为3 边是无向边. 让你输出方案数 [题 ...
随机推荐
- 关于Ubuntu 16.04 pip安装Docker-Compose
$ sudo apt-get update 安装pip: $ sudo apt-get install python-pip 卸载旧版本docker-compose: $ sudo pip unins ...
- ubuntu built-in display 产生的一个原因
在没有禁用开源的显卡驱动 nouveau 下,从 apt 安装了nvidia的驱动,导致了后面开机后,系统不能正确的识别到显示器,整个界面分辨率变的非常小,在设置菜单中的显示设置中也不能调节分辨率,并 ...
- 【PHP基础】序列化serialize()与反序列化unserialize()
序列化serialize()与反序列化unserialize(): 序列化serialize():就是将一个变量所代表的 “内存数据”转换为“字符串”的形式,并持久保存在硬盘(写入文件中保存)上的一种 ...
- 2018Ec-Final比赛总结
一场匆忙的旅程. NCC_9754_ Victory的最后一场比赛终究没能victory. 去的时候晕车到吐了两次,到宾馆吃完饭直接睡了,但还是两天都昏昏沉沉的头疼的厉害,第二天直接步行去了西工大体育 ...
- win10 解决“ 'g++' 不是内部或外部命令,也不是可运行的程序或批处理文件”的问题
https://www.jianshu.com/p/9bffbaf12bed 2. 安装MinGW 将MinGW安装在D:\mingw文件夹下(可自由选择,这里为之后添加环境变量作为范例) 安装好后选 ...
- Java 的单元测试
有点需要注意,当 JUnit 主线程退出,子线程也会跟着退出,需要使用子线程的 join() 方法使主线程等待 Maven 依赖 <dependency> <groupId>j ...
- LoadRunner使用代理远程执行提示找不到“pre_cci.c”文件
好久没有使用LoadRunner了,工作需要使用一下,执行总是提示找不到“pre_cci.c”文件,找问题花了很长时间终于找到问题了.万事还是需要找到原因: cci 会将 pre_cci.c 文件作为 ...
- python模块struct和subprocess
准确地讲,Python没有专门处理字节的数据类型.但由于str既是字符串,又可以表示字节,所以,字节数组=str.而在C语言中,我们可以很方便地用struct.union来处理字节,以及字节和int, ...
- Hibernate---开发环境搭建
下载安装Hibernate 在官网http://hibernate.org/tools/上下载eclipse安装插件的文件/安装插件的地址.点击download选择JBoss Tools,选择Arti ...
- 13 KNN背景分割器
传统的前景背景分割方法有GrabCut,分水岭算法,当然也包括一些阈值分割的算法.但是这些算法在应用中往往显得鲁棒性较弱,达不到一个好的分割效果. 现代的背景分割算法融入了机器学习的一些方法来提高分类 ...