• 【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
    ",ans);return 0;
    }//Paul_Guderian
    

    也许下一回追梦时依旧会破碎,可人生绝不该任困苦摆布并凋零。

    就算还有一丝呼吸我也要拼命追寻,只愿灿烂这平凡而不羁的生命。————汪峰《不羁的生命》

  • 相关阅读:
    SpringBoot之旅第三篇-日志
    SpringBoot之旅第二篇-配置
    SpringBoot之旅第一篇-初探
    394. 字符串解码
    1190. 反转每对括号间的子串
    921. 使括号有效的最少添加
    Leetcode 1171. 从链表中删去总和值为零的连续节点
    设计模式之过滤器模式——Java语言描述
    MySQL查询执行的基础
    设计模式之桥接模式——Java语言描述
  • 原文地址:https://www.cnblogs.com/Damitu/p/7658336.html
Copyright © 2020-2023  润新知