B. The Eternal Immortality
来源:互联网 发布:比基尼岛核试验 知乎 编辑:程序博客网 时间:2024/06/05 02:20
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.
The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).
Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.
2 4
2
0 10
0
107 109
2
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.
解题说明:此题是一道数学题,其实就是求(b-a)!,看最后一位数即可。
#include<cstdio>#include<iostream>#include<string>#include<cstring>using namespace std;int main(){unsigned long long a, b, r;scanf("%llu %llu\n", &a, &b);if ((b - a) >= 10){printf("0\n");return 0;}r = 1;while (a < b){a++;r = (r * (a % 10)) % 10;}printf("%d\n", r);}
- B. 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
- Codeforce The Eternal Immortality
- Codeforces869B 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 The Eternal Immortality 题解
- Codeforces Round #439 (Div. 2) 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
- freemark使用
- TFS映射时工作区存在报错的解决办法(一)
- python笔记
- SpringCloud第三篇-Feign
- Caffe::SetDevice 设置GPU的ID号
- B. The Eternal Immortality
- 【ZJOI2014】力
- TFS映射时工作区存在报错的解决办法(二)
- leetcode学习(3) Perfect Squares
- 剑指offer:数组中只出现一次的数字
- Ubuntu 17.04系统中使用QtCreator构建OpenCV测试工程
- 发行版本的区别(POST)
- TFS映射时工作区存在报错的解决办法(三)
- Zookeeper详解