【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 边是无向边. 让你输出方案数 [题 ...
随机推荐
- python基础数据类型之字典的操作
一. 字典的简单介绍字典(dict)是python中唯一的一个映射类型.他是以{ }括起来的键值对组成. 在dict中key是唯一的. 在保存的时候, 根据key来计算出一个内存地址. 然后将key- ...
- Percona-Tookit工具包之pt-pmp
Preface Sometimes we need to know the details of a program(porcess) when it is running even ...
- 多任务版udp聊天器
import socket import threading def send_msg(udp_socket): """获取键盘数据,并将其发送给对方"&quo ...
- 给网站添加icon图标
只需制成ico结尾的图片即可
- 汇编:1位16进制数到ASCII码转换
;============================ ;1位16进制数到ASCII码转换 ; { X+30H (0≤X≤9) ;Y= { ; { X+37H (0AH≤X≤0FH) DATAS ...
- Linux编译移植Qt5的环境_Xillinx的ZYNQ平台
Linux编译Qt环境 2017年的十一假期,足不出户,一个人在教研室里面搞Qt的移植.我手里面有Samsung的CortexA8,Samsung的 CortexA53还有Ti的Sitara系列的AM ...
- Urllib库:python内置的http请求库
1.四个模块: request error parse robotparser 2.urlopen(url, data, timeout) 发送请求 get请求无data: post请求有data 3 ...
- python分布式爬虫--房天下
第一步安装redis redis在windows系统中的安装与启动: 下载:redis官方是不支持windows操作系统的.但是微软的开源部门将redis移植到了windows上.因此下载地址不是在r ...
- [BZOJ2734][HNOI2012] 集合选数(状态压缩+思维)
Description 题目链接 Solution 可以根据条件构造出一个矩阵, 1 3 9 27 81... 2 6 18.... 4 12 36... 这个矩阵满足\(G[i][1]=G[i-1] ...
- Black Box POJ1442
Description Our Black Box represents a primitive database. It can save an integer array and has a sp ...