zoukankan      html  css  js  c++  java
  • 【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
    

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

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

  • 相关阅读:
    今天没事做了个MBTI职业倾向测试
    Prototype 源码解读[资源]
    ◎◎identity ,ident_current() ,scope_identity的区别
    进军SharePoint,资料先行....
    这两天写了个分页控件,分享代码
    高效率的object转int的函数
    可填可选的DropDownList Server Control
    [DHTML]setInterval与setTimeout的区别
    提两个建议
    通过XSL template与import实现代码重用
  • 原文地址:https://www.cnblogs.com/Damitu/p/7658336.html
Copyright © 2011-2022 走看看