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
    

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

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

  • 相关阅读:
    Linux getcwd()的实现【转】
    关于__GNU_SOURCE 这个宏---如何开启【转】
    UBI 文件系统移植 sys 设备信息【转】
    Linux USB驱动框架分析【转】
    局部变量、全局变量、堆、堆栈、静态和全局【转】
    C语言字节对齐问题详解【转】
    usb驱动的基本结构和函数简介【转】
    makefile函数集锦【转】
    非常好!!!Linux源代码阅读——内核引导【转】
    JQuery日记6.9 Promise/A之Callbacks
  • 原文地址:https://www.cnblogs.com/Damitu/p/7658336.html
Copyright © 2011-2022 走看看