10158_Factorials

2022-5-16 18:16| 发布者: Hocassian| 查看: 67| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504612509000-Problem List-采集的数据-后羿采集器.html

Pro.ID

10158

Title

Factorials

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10158

AC

54

Submit

243

Ratio

22.22%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    The factorial of an integer N, written N!, is the product of all the integers from 1 through N inclusive. The factorial quickly becomes very large: 13! is too large to store in a 32-bit integer on most computers, and 70! is too large for most floating-point variables. Your task is to find the rightmost non-zero digit of n!. For example, 5! = 1 × 2 × 3 × 4 × 5 = 120, so the rightmost non-zero digit of 5! is 2. Likewise, 7! = 1 × 2 × 3 × 4 × 5 × 6 × 7 = 5040, so the rightmost non-zero digit of 7! is 4.

    输入

    Multiple test cases. For each case, a single positive integer N no larger than 4,220.

    输出

    Description

    The factorial of an integer N, written N!, is the product of all the integers from 1 through N inclusive. The factorial quickly becomes very large: 13! is too large to store in a 32-bit integer on most computers, and 70! is too large for most floating-point variables. Your task is to find the rightmost non-zero digit of n!. For example, 5! = 1 × 2 × 3 × 4 × 5 = 120, so the rightmost non-zero digit of 5! is 2. Likewise, 7! = 1 × 2 × 3 × 4 × 5 × 6 × 7 = 5040, so the rightmost non-zero digit of 7! is 4.

    Input

    Multiple test cases. For each case, a single positive integer N no larger than 4,220.

    Output

    For each case, output a single line containing but a single digit: the right most non-zero digit of N ! .

    Sample Input

    7

    Sample Output

    4

    Source

    样例输入

    7

    样例输出

    4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部