Under construction

Still being built. Things may change

Factorial Trailing Zeros

Interview

Time limit0.5sMemory limit256 MB

Summary
Find the smallest N whose factorial has exactly M trailing zeros, or print -1 when no such N exists.
Level

Medium5 of 10

Topics
Binary search, Math
Solved
No attempts yet

Problem

가장 끝의 0의 개수가 M개인 N! 중에서 가장 작은 N을 찾는 프로그램을 작성하시오.

Input

첫째 줄에 M (1 ≤ M ≤ 100,000,000)이 주어진다.

Output

가장 끝의 0의 개수가 M개인 N! 중에서 가장 작은 N을 출력한다. 그러한 N이 없는 경우에는 -1을 출력한다.

Examples7

  1. Example 1

    Input
    1
    
    Expected output
    5
    
  2. Example 2

    Input
    2
    
    Expected output
    10
    
  3. Example 3

    Input
    3
    
    Expected output
    15
    
  4. Example 4

    Input
    4
    
    Expected output
    20
    
  5. Example 5

    Input
    5
    
    Expected output
    -1
    
  6. Example 6

    Input
    6
    
    Expected output
    25
    
  7. Example 7

    Input
    7
    
    Expected output
    30