永恒的不朽

题记

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.

Input
2 4
Output
2
Input
0 10
Output
0
Input
107 109
Output

2

**************************************************************************************************************************

这个题是b!/a!,将两者之间相同元素约掉后,这个式子便转换成(a+1)*(a+2)********b,而如果(a+1)与b之间十位数不同,则一定会乘到类似10,20,30,个位数将会变为0.所以,可以先判断个位数为0的情况

		if(b-a>=10){
			printf("0\n");
			continue;
		}
		a%=10;
		b%=10;	
		if(b<a)
			printf("0\n");
如果十位数相同,则只需要将(a+1),(a+2),,,,b的个位数相乘,可以用取余10,来简化计算,因为,我们只需要求得最后一位数字是多少,所以不用管其他位上的数字


#include <stdio.h>
long long int a,b,d;
int main(){
	int c;
	while(~scanf("%lld %lld",&a,&b)){
		d =1;
		c=1;
		if(b-a>=10){
			printf("0\n");
			continue;
		}
		a%=10;
		b%=10;	
		if(b<a)
			printf("0\n");
		else{
			for(int i=a+1;i<=b;i++){
				d*=i;
				d%=10;
			}
			printf("%d\n",d);
		}
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CSDN作为一个专业的IT技术社区,其重要性在于提供了一个平台,让技术爱好者和专业人士可以分享和交流他们的知识和经验。不管是新手还是资深工程师,通过CSDN,他们都能找到自己所需的学习资源和解决问题的方法。 首先,CSDN提供了丰富多样的技术文章和博客,涵盖了各个领域的前沿趋势和最新技术。这些文章不仅来源于社区成员的原创,还来自于知名媒体和专业编辑的精选。通过阅读这些文章,用户可以不断跟进行业动态,了解最新技术的发展,并从中获取灵感和启发。 其次,CSDN还为用户提供了一个交流互动的平台。用户可以在论坛上发起问题、分享自己的经验,得到其他用户的帮助。无论是遇到技术难题还是想要研讨某个话题,CSDN的论坛都能成为一个很好的交流场所。通过和其他技术人员的互动,用户可以扩展自己的视野,获得不同的观点和思路。 除了文章和论坛,CSDN还定期举办各种线上和线下的技术沙龙和活动。这些活动不仅提供了实践的机会,还能让用户与业界大牛面对面交流,拓展人脉和学习机会。通过参与这些活动,用户可以不仅加深对技术的理解和掌握,还能提升自己的综合能力和职业竞争力。 总之,CSDN作为一个不朽的艺术,不仅通过为用户提供丰富的技术资源满足其学习需求,还激发了用户的创造力和创新思维。通过CSDN,人们得以共同打造一个技术分享的平台,让知识和经验得以传承和发展。无论是从个人的成长,还是技术行业的发展,CSDN都起到了积极的推动和促进作用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值