博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces 869B The Eternal Immortality
阅读量:5128 次
发布时间:2019-06-13

本文共 1792 字,大约阅读时间需要 5 分钟。

The Eternal Immortality

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.

Example
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.

题意是:求一个数的阶乘除以另一个数的阶乘的最后一位。
思路是如果两个数的差大于九(或者五),最后一位肯定是0.如果不是的话就从a遍历到b求出最后一位。
#include
#include
#include
using namespace std;int main(){ long long m,n; while(~scanf("%lld%lld",&n,&m)) { long long ans=1; if((m-n)>9) { printf("0\n"); continue; } for(long long i=n+1;i<=m;i++) { ans*=i; ans%=10; } printf("%lld\n",ans); }}

 

转载于:https://www.cnblogs.com/da-mei/p/9053332.html

你可能感兴趣的文章
C#基础知识面试经典[整理]
查看>>
美图秀秀首页界面按钮设计(二)
查看>>
通过修改CoreCLR中的ClrHost实现自托管程序
查看>>
Dojo—ajax框架实战
查看>>
VideoView获取本地视频播放
查看>>
MySQL数据备份之mysqldump使用
查看>>
【HDU6609】Find the answer【线段树】
查看>>
shell习题第5题:批量更改文件后缀名
查看>>
SQL基础教程
查看>>
Autofac - 生命周期的理解
查看>>
【HEVC帧间预测论文】P1.3 Fast Inter-Frame Prediction Algorithm of HEVC Based on Graphic Information...
查看>>
ECMAscript v.s. Javascript
查看>>
View State
查看>>
HTML标记参考手册
查看>>
svn服务器搭建
查看>>
使用SpringAop 验证方法参数是否合法
查看>>
关于Microsoft.SharePoint.Security的问题
查看>>
AndroidManifest.xml详解
查看>>
vue学习二:
查看>>
在IIS上部署的网站,本机无法浏览解决方法
查看>>