Codeforces869B The Eternal Immortality
来源:互联网 发布:程序员为什么容易猝死 编辑:程序博客网 时间:2024/06/05 09:44
标签:模拟,数学
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 everya! 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 ofb! 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 integersa 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 longusing 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
- Codeforce The Eternal Immortality
- B. The Eternal Immortality
- codeforces The Eternal Immortality 题解
- CF 869 B. The Eternal Immortality【数学】
- Codeforces 869B. The Eternal Immortality
- CodeForces 869B The Eternal Immortality
- codeforces 869B The Eternal Immortality
- codeforces 869B The Eternal Immortality
- Codeforces Round #439 (Div. 2) The Eternal Immortality
- Codeforces Round #439 (Div. 2) B. The Eternal Immortality
- Codeforces Round #439 (Div. 2) B. The Eternal Immortality
- codeforces—— 869B —— The Eternal Immortality
- Codeforces Round #439 (Div. 2) B. The Eternal Immortality
- Codeforces Round #439 (Div. 2) The Eternal Immortality
- codeforces 869BThe Eternal Immortality
- HDU6138 Fleet of the Eternal Throne
- HDU 6138 Fleet of the Eternal Throne
- 打印重复姓名和重复次数
- 10.7
- 台湾大学机器学习基石Lecture2
- 扩展欧几里得 与 乘法逆元
- nrpe安装
- Codeforces869B The Eternal Immortality
- new运算符做了什么
- 使用VUE-CLI构建一个项目基本的配置
- Python之dict的妙用
- leetcode 333. Largest BST Subtree
- SSM中解决中文乱码问题
- 使用libpcap库过滤pcap文件中的数据包
- bzoj2369 && 2687 -- 决策单调性优化DP
- NKOJ-Unknow 死亡的颂唱者